• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Error :java.sql.SQLException: Invalid column index

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

I have written a procedure in oracle which goes a below




Now I am calling this procedure in java class file



While I execute the proc in sql console i get all the multiple records. Where as i while i try to display it in front end i get the error
Error :java.sql.SQLException: Invalid column index

Please let me know how to retrieve multiple records from proc in java. Am i doing wrong in the above code..please let me know
 
author & internet detective
Posts: 42105
933
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eshwar,
What do you want your stored procedure to return? Right now, it looks like it just prints out a bunch of stuff and returns nothing.
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
extremely sorry. i want password to return from proc, so that same can be displayed in front end
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
stored procedure do not return value, however function does that.

So do function needs to be used here instead of proc.

Can anybody please explain how the below problem could be solved.
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not getting how to return multiple values from procedure. From the below program, when i print (String)cs.getObject(2); i am getting just the first record from the procedure.

Please let me know how to get the multiple results. Also, let me know how to return values from procedure.

Thanks in advance
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one suggest some idea on this
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.oradev.com/ref_cursor.jsp check this link .
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your case your procedure should return 1 row.

so you should replace this:


with this:
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks All.

Krishna, the link you provided was really very helpful.

However, small clarification, in the article, the ref cursor package is declared as below.



Where EMP is a table name and declared with attribute ROWTYPE.

I have a requirement where the I need to pull the records from five different tables using joins. In that case should i give any one of the table name in place of EMP in above package

As I am not using all the column values of every individual table, do I need to give attribute ROWTYPE.

Please let me know.



 
krishna bala
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

 
You showed up just in time for the waffles! And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic