• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL invalid column index

 
Aabha Varma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a procedure that returns me Ref cursor.
the object that i am returning is a table of records that have two columns. Both the record and the table is created permanently in db.

I am calling the procedure from java.
The procedure when run separately, gives me two rows with value.

Now when i take a result set of the cursor, and if i give rs.getInt(column name) it gives me an invalid column index.

But the resultset meta data gives me the information that there are two columns.
So now i am stuck as where to debug.

Can anybody help me out

Thanks in advance
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aabha ,
Check Whether the sql Query returning the ResultSet has the column name mentioned in "rs.getInt(column name)". Also check if you are using alises like "e.EmpName" in that case you can rewrite the query like
Select e.EmpName EmpName from Emp e

Note : I guess it's not the right place to post this question. If you have posted it at right place you 'll get more responses from the ranchers.
 
Aabha Varma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I am calling a procedure which returns me a REF cursor.

Thanks for telling me the place to put the query.
I have posted the same in jdbc forum
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even while returning a Ref Cursor. You need to have some SQL that creates the Ref cursor in the stored procedure. Check that out.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know why this is in the Swing forum; it clearly belongs in JDBC. I'll move it there for you.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Aabha MMT",

Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place, and wastes the bartender's time having to close and move posts around.

Additionally, please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Aabha Varma
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding naming convention..
Its my real name and MMT is my initial.

Posting the same querry twice. It was a mistake. but somebody pointed it out that there is a better place to put up such query. And thats the reason why its there in second place.

Rgds,
Aabha
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34210
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aabha,
No problem. In the future, you can just ask a bartender/sherriff to move the post for you without having to create a copy.

I don't think Bear was questioning whether Aabha was your real first name. It was probably the lack of vowels in the last name "MMT". We prefer you use a last name, not just initials.
 
Anandh Ramesh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

during retrieval, you can retrive the data in the same order as you have selected.

for example, if your query reads "select a,b,c from xyz" retrieve the values in the same order as a, then b, and finally c.

this has worked for me.

all the best...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic