I am trying to pass array of values from java to PL/SQL function. I am trying as below,
String[] array = {"70" , "2" , "4" , "9" , "329" , "13" , "49" , "33"};
Connection cnn=DriverManager.getConnection(url, username, password);
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("VLIST", cnn);
ARRAY array_to_pass = new ARRAY(descriptor, cnn,array);
OracleCallableStatement pstmt = (OracleCallableStatement) cnn.prepareCall("{? = call GETSRCHLST2(?)}");
pstmt.registerOutParameter(1, Types.VARCHAR);
pstmt.setArray(2, array_to_pass);
pstmt.execute();
String output = pstmt.getString(1);
out.println(output+"\n"+ " "+array_to_pass.length());
Here in the function call no content of array is getting passed but array_to_pass.length() is 8.
Oracle procedure:
CREATE OR REPLACE FUNCTION EDR.GETSRCHLST2(VV VLIST) RETURN VARCHAR2 IS
BN NUMBER;
STRS VARCHAR2(9000):='start';
HH varchar2(30);
BEGIN
STRS:=STRS || '- LIST COUNT: '||VV.COUNT||' - ';
BN:=VV.FIRST;
WHILE BN IS NOT NULL
LOOP
HH:=VV(BN);
STRS:=STRS||HH||' , ';
BN := VV.NEXT(BN);
END LOOP;
RETURN STRS;
EXCEPTION WHEN OTHERS THEN RETURN 'SOME ERROR'||SQLERRM;
end;
Can anyone tell me, where i am going wrong?