在我的例子中,Dbms_Lob.CreateTemporary的Duration参数是Dbms_Lob.SESSION,但是根据oracle documentation:
The duration parameter passed to dbms_lob.createtemporary() is a hint.
The duration of the new temp LOB is the same as the duration of the
locator variable in PL/sql. For example,in the preceding program
block,the program variable a has the duration of the residing frame.
Therefore at the end of the block,memory of a will be freed at the
end of the function.
因此,离开功能块后,Oracle可能会销毁BUFFER CLOB.我可以看到,在某些情况下,当BUFFER超过32K时,我无法读取它从Java(JDBC)端以这种方式返回的值.
解决方法
clob.getSubString(0,clob.length())
throws:java.sql.sqlException:
while
Invalid argument(s) in call at
oracle.sql.CLOB.getSubString(CLOB.java:236)clob.length()
returns actual length of my clob
getSubString
的文档指出:
pos – the first character of the substring to be extracted. The first character is at position 1.
有了生成和返回CLOB的简单函数,我可以通过JDBC(ojdbc5或ojdbc6)检索它,没有任何问题,无论是使用getCLOB()还是getString().但是,如果我尝试将使用getCLOB检索的Oracle.sql.CLOB分配给String
String x = getSubString(0,clob.length());
然后我也在调用错误中得到Invalid参数.只需将其更改为:
String x = getSubString(1,clob.length());
作品.所以它似乎与函数中的临时分配或CLOB大小无关.我不明白为什么你没有小CLOB的问题 – 也许你的逻辑只是在他们很小的时候没有打到这个?
与此同时,你已经使用clob.getCharacterStream().read()解决了这个问题,所以现在这可能有点无关紧要了.