-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Sajidnet2
Message 1 in Discussion
Hi
I created the following types in the oracle db
CREATE TYPE number_array AS table of NUMBER(38);
CREATE TYPE varchar_array AS table of VARCHAR2(50);
CREATE TYPE EMPLOYEE AS OBJECT(EmpName varchar_array,EmpNo number_array);
then i wrote a java class
// Connect to the database
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver ());
OracleConnection conn = (OracleConnection)
DriverManager.getConnection(driverURL,"user", "pwd");
ArrayDescriptor arrayDescEmpNo = ArrayDescriptor.createDescriptor("NUMBER_ARRAY",
conn);
ArrayDescriptor arrayDescEmpName = ArrayDescriptor.createDescriptor("VARCHAR_ARRAY",
conn);
String[] empname = new String[]{"Hello","Emp"};
int[] empno = new int[]{12,13};
ARRAY arrayEmpName = new ARRAY(arrayDescEmpName, conn, empname);
ARRAY arrayEmpNo = new ARRAY(arrayDescEmpNo, conn, empno);
// in the type map, add the mapping of EMPLOYEE SQL
// type to the EmployeeObj custom Java type
Map map = conn.getTypeMap();
map.put("EMPLOYEE", Class.forName("EmployeeObj"));
// Create a SQLData object EmployeeObj in the SCOTT schema
EmployeeObj e = new EmployeeObj("EMPLOYEE", arrayEmpName, arrayEmpNo);
//I pass the employee object to the java stored procedure
CallableStatement stmt = null;
stmt = conn.prepareCall("{ ?=call JavaSP(?) }");
stmt.setObject(2, e, OracleTypes.STRUCT);
stmt.registerOutParameter(1, Types.LONGVARCHAR);
stmt.execute();
Now my question is how do i retreive the values of the Employee object in the java
stored procedure ??
Note: JavaSP is sql function defined as
CREATE OR REPLACE FUNCTION JavaSP(emp IN EMPLOYEE) RETURN STRING AS LANGUAGE JAVA NAME
'JavaSP.getValue(EmployeeObj) return java.sql.String';
Now in the getValue(EmployeeObj) how will i retreive the values i inserted
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]