wood burning stoves 2.0*
The moose likes JDBC and the fly likes Missing IN or OUT parameter at index:: 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Missing IN or OUT parameter at index:: 1" Watch "Missing IN or OUT parameter at index:: 1" New topic
Author

Missing IN or OUT parameter at index:: 1

toukhir mujawar
Ranch Hand

Joined: Oct 11, 2006
Posts: 70
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
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

Your subquery does not return any records so you end up with "select something from somewhere where value in ()"


My Blog: Down Home Country Coding with Scott Selikoff
toukhir mujawar
Ranch Hand

Joined: Oct 11, 2006
Posts: 70
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

Joined: Oct 11, 2006
Posts: 70
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
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Missing IN or OUT parameter at index:: 1
 
Similar Threads
with Java: how to update a row in sybase with string having a single quote
SQLException caught: ORA-17041: (no message for error) 1
Using Like in preparedstatement
ejbSelect method problem
Batch update in EJB