Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error :java.sql.SQLException: Invalid column index

 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34423
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
extremely sorry. i want password to return from proc, so that same can be displayed in front end
 
Prakash Kumar M
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Can any one suggest some idea on this
 
krishna bala
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.oradev.com/ref_cursor.jsp check this link .
 
Charbel Keyrouz
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic