Link to home
Start Free TrialLog in
Avatar of chelsia11
chelsia11

asked on

SQL query in Java with variable in where clause

I am trying to execute a SQL Query from Java.

String c_Name="USA";

String strQuery =  "select name from multiple_value where object_name = 'HUB_'\"+c_Name";

I want the value of c_Name to be replaced at runtime based on the value of c_Name. So query when evaluted should look like

String strQuery =  "select name from multiple_value where object_name = 'HUB_USA";

Please let me know how to do this.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Use a PreparedStatement
Avatar of chelsia11
chelsia11

ASKER

Can't use a PreparedStatement, since it's not a SQL but DQL (Documentum Query language). I just need the mechanism to do this which would be the same in SQL and DQL.
ASKER CERTIFIED SOLUTION
Avatar of thomas908
thomas908

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial