More advanced example request
Brian Etheridge, November 01, 2005 - 7:38 am UTC
Hi,
Your response to 'Can I Pass a nested table to Java from a pl/sql procedure' was excellent. I am using this technique successfully, however, I have suddenly hit a problem when I try to pass a nested table of my own objects:
create or replace type MyObject as object(
TypeName varchar2(128),
Name varchar2(128),
OtherName varchar2(128),
Comment varchar2(128)
);
create or replace type MyObjectList as table of MyObject;
Everything looks fine, everything loads OK into Oracle (10g rel 1), but I get a ClassCastException at runtime in the Java code on the line:
MyObject[] myObjectAry = (MyObject[])p_myObjectArray.getArray();
Should I be able to pass my objects or are we restricted to Oracle classes, primitives or certain Java classes, like String?
Composite nested table
A reader, November 18, 2008 - 7:02 am UTC
Dear Tom,
What if the nested table was constructed of composite type, for example:
CREATE OR REPLACE TYPE OBJ1 AS OBJECT (
COLUMN1 VARCHAR2(10),
COLUMN2 VARCHAR2(10));
CREATE OR REPLACE TYPE TAB1 AS TABLE OF OBJ1;
What changes would be required?
November 18, 2008 - 7:43 pm UTC
read up one review... jpublisher.
Objects in nested tables
Tamas Foldi, January 25, 2009 - 6:03 am UTC
Objects in nested tables can be used the same way:
(consider nestedTable as oracle.sql.ARRAY - a nested table with object types inside)
Object[] nestedObjects = (Object[]) nestedTable.getArray();
oracle.sql.STRUCT firstObject = (oracle.sql.STRUCT)nestedObjects[0];
String firstColumn = firstObject.getAttributes()[0];
Jpub is a great tool, but for simple tasks a handcrafted java code is cleaner and takes less dependecies
Using Nested Table in Java
shyam, October 23, 2010 - 5:57 am UTC
Hi Tom,
I have requirement in which i need to call a java procedure in which i need to pass 1 parameter integer and the return type of that function is nested.
I am using Callable statement to call the procedure,but i am not aware what data-type need to choose in the input and how to handle the result of the procedure i.e how to get hold of result.
ARRAY array;
try {
cs = con.prepareCall(pvsolprocedure);
cs.registerOutParameter(1,Types.ARRAY);
cs.setString(2,"india");
cs.execute();
array=(ARRAY) cs.getArray(1);
This is my code snippet which is resulting unsupported exception
Thanks,
Shyam.S
Retrieving CLOB from object
RafaĆ Sobieraj, August 06, 2012 - 10:19 am UTC
Hi Tom,
How can I get contents of a CLOB from an oracle object?
My object definition is:
create or replace type zip_file is object
(
FILE_NAME VARCHAR2(100),
FILE_CONTENTS CLOB
);
create or replace type zip_files as table of zip_file;
... and code is:
Object[] nestedObjects = (Object[]) zip_files.getArray();
oracle.sql.STRUCT firstObject = (oracle.sql.STRUCT)nestedObjects[0];
I am able to get contents of a FILE_NAME field, but FILE_CONTENTS is like 'oracle.sql.CLOB@9b6a5f7f'. Is there a posibility to get CLOB value from an object?