Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Trouble with OracleCallableStatement

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic