Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Java Stored Function can't return strings longer than 4096 chars (ORA-24345)
I'm running into a size limit that I don't think I should be running into (what else is new). I'm writing a Java stored function and I'm getting an ORA-24345 (A Truncation or null fetch error occurred). I can write a PL/SQL stored function that returns a 32k varchar2. See Sample code below.
Does anyone know why this is? It really looks like a bug. Can someone try it on a different platform?
Here's what I'm running on:
Oracle8i Enterprise Edition Release 8.1.7.0.1 - Production JServer Release 8.1.7.0.1 - Production
RedHat Linux 6.2 with stock SMP kernel version 2.2.14 on a 2 processor 800 Mhz Dell PowerEdge 1400 with 512 MB RAM.
SAMPLE CODE: Here's the Java class:
class CTest
{
public static String getStringJava( int nSize )
{
char arrayChars[] = new char[ nSize ];
for ( int nIndex = 0;
nIndex < arrayChars.length; nIndex++ ) { arrayChars[nIndex] = 'X';
return new String( arrayChars );
}
}
Here's the publishing script and test driver:
create or replace function getStringJava( nSize number )
return varchar2 as language Java name 'CTest.getStringJava(int) return java.lang.String';/
strReturnPLSQL VARCHAR2(32000); strReturnJava VARCHAR2(32000);
END;
/
exit
-- snip snip ---
Here's the output I get:
Function created.
length of strReturnPLSQL = 32000
length of strReturnJava = 4096
ERROR:
ORA-24345: A Truncation or null fetch error occurred
Thanks.