• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in calling the Function

 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Friends i have a function in oracle thats returns a character Types.CHAR
I'm calling the function like this.


Is this the correct way to call. I'm getting the following exception

java.sql.SQLException: Invalid column index
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Srini,

Just noticed one thing,
is it typing error

follwoing line has 3 doube quote(")

"stmt = conn.prepareCall("{ ? = call GET_SHIFT_ID()}");


please confirm ???

thanks
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shailesh Chandra:



follwoing line has 3 doube quote(")

"stmt = conn.prepareCall("{ ? = call GET_SHIFT_ID()}");

please confirm ???

thanks



Sahilesh Sorry that double quotes is a typo .. it's not in the code.
Also My code got compiled .
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats what I was thinking about compiling error,
since complete code was not here so I thought might be some other quote is complementing it.

I dont find anything wrong with given code,

Can u paste more code or stack trace of exception

I think error is at some other line
[ January 07, 2005: Message edited by: Shailesh Chandra ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all i even tried this way



But still i'm getting error

[ January 07, 2005: Message edited by: srini vasan ]
[ January 07, 2005: Message edited by: srini vasan ]
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Srini,

can you check if colon " : " is really needed while calling method,


I am not very much sure about it , but try same.



and give system.out on every alternate line so you can get exact place of error.


thanks
[ January 07, 2005: Message edited by: Shailesh Chandra ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shailesh Chandra:
[QB]Srini,

can you check if colon " : " is really needed while calling method,

I am not very much sure about it , but try same.

and give
system.out only every alternate line


Yes Shailesh..
I'm trying to give SOP in alternate lines.
But ii dint use the ":" before, after seeing google
i tried with that also ..

 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One thing i'wd like to add.
The return type of the function is Char.
So i registered the out Parameter as Types.CHAR.
But for getting the value i user stmt.getString(1), will this wrk.
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my view It will work, but I will prefer

Char c = (Char) stmt.getObject(1);
or
String s = (String) stmt.getObject(1);

thanks
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it worked.. But still i cant understand the problem.
Oracle returns a single Character.
I got the value in this way, shiftId = stmt.getString(1);
But in the console i saw that the value of shiftID is of length 255 in which the first character is the return value & the rest is padded with empty spaces, then i used the trim() method it's working.
Any reason for this.
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had faced similar problem few month back,

if using oracle execute follwing command on sqlplus

show parameter cursor_sharing;

and if value of parameter is SIMILAR then might be you are having same reason for this.

thanks
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does this "show parameter cursor_sharing;" means ?
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is one of oracle's parameter, I had faced similar problem because of this parameter

you can refer my old post here


just a thought that you may be having similar problem

thanks
[ January 07, 2005: Message edited by: Shailesh Chandra ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Shailesh ..
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic