This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Missing IN or OUT parameter at index:: 1

 
toukhir mujawar
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • 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.....
 
Scott Selikoff
author
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic