wood burning stoves*
The moose likes JDBC and the fly likes Trouble with OracleCallableStatement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Trouble with OracleCallableStatement" Watch "Trouble with OracleCallableStatement" New topic
Author

Trouble with OracleCallableStatement

John Eric Hamacher
Ranch Hand

Joined: Apr 25, 2007
Posts: 230
Hi . . .

I am receiving the following exception: wrong number or types of arguments in call to 'FUNCTION_A'


Here are defined types:

create or replace TYPE NET_CHARTS_CHAR_ARRAY AS VARRAY(3) OF CHAR(10);
create or replace TYPE NET_CHARTS_NUMBER_ARRAY AS VARRAY(3) OF NUMBER;

Here is FUNCTION_A:

TYPE array_number IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;

FUNCTION dial_chart_def(
field_a IN OUT ARRAY,
field_b IN ARRAY,
field_c IN OUT array_number,
field_d IN NUMBER, --unit is inches
field_e IN NUMBER, --unit is inches
field_f IN VARCHAR2,
field_g IN NUMBER DEFAULT cDefaultDPI,
field_h IN NUMBER DEFAULT cDefaultfontScale)
RETURN VARCHAR2;

Here is my Java code:

OracleCallableStatement proc = (OracleCallableStatement)
conn.prepareCall("{ ? = call net_charts.function_a(?,?,?,?,?,?,?,?) }");

proc.registerOutParameter(1, Types.VARCHAR);

ArrayDescriptor arrayDescVarchar = ArrayDescriptor.createDescriptor("NET_CHARTS_CHAR_ARRAY", conn);
ArrayDescriptor arrayDescDouble = ArrayDescriptor.createDescriptor("NET_CHARTS_NUMBER_ARRAY", conn);
ARRAY labels = new ARRAY(arrayDescVarchar, conn, aLabels);
ARRAY colors = new ARRAY(arrayDescVarchar, conn, aColors);
ARRAY values = new ARRAY(arrayDescDouble, conn, aValues);

proc.setARRAY(2, labels);
proc.registerOutParameter(2, Types.ARRAY);
proc.setARRAY(3, colors);
proc.setARRAY(4, values);
proc.registerOutParameter(4, Types.ARRAY);
proc.setInt(5, 4);
proc.setInt(6, 2);
proc.setString(7, "aString");
proc.setInt(8, 300);
proc.setDouble(9, (300/72));
proc.execute();
String value = proc.getString(1);
proc.close();
return value;


Any ideas?

Can I use NET_CHARTS_NUMBER_ARRAY in place of "array_number" is the type for parameter 4? My code cannot locate "array_number" on the database for some reason.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble with OracleCallableStatement
 
Similar Threads
Stored procedure which returns array
help in creating procedure
calling stored procedures regarding STRUCTS of JDBC
Getting a resultSet from a CallableStatement
How to pass a two dimensional Object Array To a Stored Procedure