Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > Return Jav String Array to Oracle Stored Procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-21-03, 13:18
olerag olerag is offline
Registered User
 
Join Date: Aug 2003
Posts: 40
Return Jav String Array to Oracle Stored Procedure

OK - tried via a stored procedure. This time I'm getting a similar
Oracle exception:
ORA-00932: inconsistent datatypes: expected Invalid Java signature
Any suggestions/help would be greatly appreciated. The complete
code is provided below:

a) Stored Oracle Type...

CREATE OR REPLACE TYPE StringArrayType AS TABLE OF VARCHAR2(100)
/

b) Stored Java class...

CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "JavaArrayWrapper" AS

import oracle.jdbc.driver.*;
import oracle.sql.*;
import java.sql.*;

public class MyJavaArray {

public static void setArray() {
String s[] = new String[10];

for (int i=0; i<s.length; i++) {
s[i] = "Entry " + (i+1) ;
}

try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = myOpenConnectionClass();
OracleCallableStatement cs = (OracleCallableStatement)conn.prepareCall("{call MyTestWrapper(?)}");
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("STRINGARRAYTYPE" , conn);
ARRAY a = new ARRAY(desc, conn, s);
cs.setARRAY(1,a);
cs.execute();
cs.close();
conn.close();
}
catch (SQLException sql) {
}
}
}
/

c) Stored PL/SQL wrapper procedure...

CREATE OR REPLACE PROCEDURE MyTestWrapper(vArray OUT StringArrayType) IS
LANGUAGE JAVA NAME 'MyJavaArray.setArray()';
/

d) A pl/sql implementation block...

SET SERVEROUTPUT ON
DECLARE
vArray StringArrayType;
BEGIN
MyTestWrapper(vArray);
DBMS_OUTPUT.ENABLE(1000);
FOR i IN 1..vArray.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(vArray(i));
END LOOP;
END;
/
SET SERVEROUTPUT OFF
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On