You may get ORA-22275 in the following situation:
declare l_clob clob; begin l_clob := dbms_xmlgen.getxml('select * from user_tables'); dbms_lob.freetemporary(l_clob); insert into files(document) values(l_clob); end; / ORA-22275: invalid LOB locator specified ORA-06512: at line 6
The problem here is in the premature call of procedure DBMS_LOB.FREETEMPORARY, although the error is raised in the subsequent line.
This particular instance of DBMS_XMLGEN.GETXML is returning a temporary LOB that must be freed after use, therefore DBMS_LOB.FREETEMPORARY must be called after moving the LOB object into its "final" position inside the table.
When you insert a temporary LOB into a table, it becomes persistent.
See also see entry for another occurrence of ORA-22275.
See message translations for ORA-22275 and search additional resources.