Thanks<br />Nithya<br />Sun Certified Java 2 Programmer
Thanks<br />Nithya<br />Sun Certified Java 2 Programmer
Thanks<br />Nithya<br />Sun Certified Java 2 Programmer
Originally posted by Beksy Kurian:
I overlooked the object part.
I do not have a tested example. The following is a sample code I saw in one of the Oracle sites.
in PL/SQL------
create or replace type rectype as object(col1 varchar2(10),col2 varchar2(10));
/
create or replace package ioStruct as
procedure testproc(iorec in out rectype,orec out rectype);
end ioStruct;
/
create or replace package body ioStruct as
procedure testproc(iorec in out rectype,orec out rectype) is
begin
orec := iorec;
iorec.col1 := orec.col2;
iorec.col2 := orec.col1;
end testproc;
end ioStruct;
/
and in java----
{
// First declare the object arrays that will store the data.
Object [] p1obj = {"First","Second"};
Object [] p2obj = {};
// Now Declare a descriptor to associate the host object type with the
// record type in the database.
StructDescriptor desc1=StructDescriptor.createDescriptor("RECTYPE",conn);
// Now create the STRUCT objects to associate the host objects
// with the database records.
STRUCT p1struct = new STRUCT(desc1,conn,p1obj);
STRUCT p2struct;
// Declare the callable statement.
// This has to be of type OracleCallableStatement to use:
// setOracleObject(
// and
// registerOutParameter(position,type,oracletype)
OracleCallableStatement ocs =
(OracleCallableStatement)conn.prepareCall("{call iostruct.testproc(?,?)}");
// The first parameter is in out so we have to use setOracleObject to
// pass it to the statement.
ocs.setOracleObject(1,p1struct);
// The first parameter is in out so we have to Register the parameter as well.
// Note the reuse of the TYPE.
ocs.registerOutParameter(1,OracleTypes.STRUCT,"RECTYPE");
// The second parameter is out so that has to be registered too.
// Note the re use of the TYPE.
ocs.registerOutParameter(2,OracleTypes.STRUCT,"RECTYPE");
// Execute the procedure.
ocs.execute();
// Associate the returned arrays with the ARRAY objects.
p1struct = ocs.getSTRUCT(1);
p2struct = ocs.getSTRUCT(2);
// Get the data back into the data arrays
p1obj = p1struct.getAttributes();
p2obj = p2struct.getAttributes();
// Show the results:
System.out.println("First Object is now "+p1obj[0]+" and "+p1obj[1]);
System.out.println("Second Object is now "+p2obj[0]+" and "+p2obj[1]);
}
Regards
Beksy
Thanks<br />Nithya<br />Sun Certified Java 2 Programmer
Originally posted by Beksy Kurian:
I have answered to your 'own' thread, Bobby
Beksy
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|