Hi
I am using a WLI 8.5 database control to call a Stored Procedure that accepts a parameter of type object and returns an Object.
Though i have used the same code which has been posted some weeks back Im unable to map the java type(java.sql.STRUCT) with an equivalent SQL Type. It throws me an exception while conversion.
I would appreciate if anyone would share the solution.
Snippet Java code
SQLParameter[] params = new SQLParameter[2];
try
{
Object[] recType=new Object[2];
recType[0]=new String("Krishna");
recType[1] = new String("Kishore");
// Now Declare a descriptor to associate the host object type with the
// record type in the database.
StructDescriptor desc1=StructDescriptor.createDescriptor("RECTYPE",dbCtrl.getConnection());
// Now create the STRUCT objects to associate the host objects
// with the database records.
STRUCT p1struct = new STRUCT(desc1,dbCtrl.getConnection(),recType);
STRUCT p2struct=null;
params[0] = new SQLParameter(p1struct, Types.STRUCT, SQLParameter.INOUT);
params[1] = new SQLParameter(p2struct, Types.STRUCT, SQLParameter.OUT);
try
{
System.out.println(params[0].value.toString());
dbCtrl.SendValue(params);
}
catch(SQLException sqlEx)
{
sqlEx.printStackTrace();
}
Oracle Procedure
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;
/
Thanks.
Kishore