• 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

Missing IN or OUT parameter at index:: 1

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
friends i have a problem....

PreparedStatement st= conn.prepareStatement("select sum(amount) from tbl_daily_collection where user_code in (select distinct subdiv from tbl_admcd where div = ?)");
st.setInt(1,user);

ResultSet rs = st.executeQuery();

i m getting the error message Missing IN or OUT parameter at index:: 1

please help me.....
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your subquery does not return any records so you end up with "select something from somewhere where value in ()"
 
toukhir mujawar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry man... my subquery

"select distinct subdiv from tbl_admcd where div =?" is working well..and returning some value as well...
 
toukhir mujawar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried this on SQL prompt

select sum(amount) from tbl_daily_collection where user_code in (select distinct subdiv from tbl_admcd where div =645

it is woeking.... but not that in java.....


PreparedStatement st= conn.prepareStatement("select sum(amount) from tbl_daily_collection where user_code in (select distinct subdiv from tbl_admcd where div = ?)");
st.setInt(1,user);
ResultSet rs = st.executeQuery();


please help me...
 
Scott Selikoff
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure the subquery returns any values in java? Try running the subquery in java and see.

Not that java has anything to do with it, its most likely a user ownership issue. Often times you need to specify the table owner in the table name such as dbo.tbl_admcd. Query analyzers often fill in missing info without telling you which is why it appears to work outside of java, your query analyzer is being clever and it probably should give the same error java is reporting, that there subquery is returning no data for the in clause.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic