Using the setString method for dynamic string
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Vernon_WOO
Posted On:   Friday, August 2, 2002 05:08 PM

Here is a query I need to run: select lastname from account where userid in ( ? ) When call the setString method, the argument can be 'Joe' or 'Joe', 'Tom' or 'Joe', 'Tom', 'John' ... The qurey select lastname from account where userid in ('Joe', 'Tom', 'John') returns a correct result. However, String str="select lastname from account where userid in ( ? )"; Statement st=connection.PrepareStatement(str); st.setString(1, X); either X is 'Joe', 'Tom' or "'Joe', 'Tom'" or "Joe, Tom" return the right data Is any solution for this problem? Than   More>>

Here is a query I need to run:

select lastname from account where userid in ( ? )

When call the setString method, the argument can be

'Joe' or
'Joe', 'Tom' or
'Joe', 'Tom', 'John' ...

The qurey

select lastname from account where userid in ('Joe', 'Tom', 'John')

returns a correct result. However,

String str="select lastname from account where userid in ( ? )";
Statement st=connection.PrepareStatement(str);

st.setString(1, X);

either X is
'Joe', 'Tom' or
"'Joe', 'Tom'" or
"Joe, Tom"
return the right data

Is any solution for this problem?

Thanks,

v.

   <<Less
About | Sitemap | Contact