• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

SQL invalid column index

 
Greenhorn
Posts: 22
  • 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 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
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67554
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 40678
827
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
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.
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic