LOB locater from Java?
I seem to be having a problem with getting a CLOB from a Java stored procedure. I have
public class TheJava {
...
public static CLOB getData(int arg){. . .
which is specified by
FUNCTION getClobData(a IN NUMBER)RETURN CLOB
AS LANGUAGE JAVA
NAME 'TheJava.getData(int) return oracle.sql.CLOB'
I also have the utility procedure to write it out
PROCEDURE printClobOut(result IN OUT NOCOPY CLOB) is
xmlstr varchar2(32767);
line varchar2(2000);
begin
xmlstr := dbms_lob.SUBSTR(result,32767);
loop
exit when xmlstr is null;
line := substr(xmlstr,1,instr(xmlstr,chr(10))-1);
dbms_output.put_line('| '||line);
xmlstr := substr(xmlstr,instr(xmlstr,chr(10))+1);
end loop;
end;
So if I try
declare
c CLOB;
begin
dbms_lob.createtemporary(c,true);
c:=getlegendasxml(1);
printclobout(c);
dbms_lob.freetemporary(c);
end;
I get
ORA-22275: invalid LOB locator specified
ORA-06512: at "SYS.DBMS_LOB", line 739
ORA-06512: at "PRINTCLOBOUT", line 5
ORA-06512: at line 6
Really, I have no idea what I have to do to get the right locater. Any suggestions are much appreciated.