Hi,
I have a problem related to passing a number of parameters (the number changes dynamically) for the IN operator in the WHERE clause of a select statement. I want to have a static query e.g. "select * from emp where emp_name in (?, ?, ?, ....)". Here the number of place holders are known only at runtime which would depend on the number of employee names in the list chosen by the user. The list e.g. is:
String emp_names = "'A', 'B', 'C', 'D'";
I want to keep the query static but at the same time be able to provide N number of parameters to this query at run time. Even better if there is a workaround to having N number of placeholders. Having too many placeholders in the query doesn't look like a good idea. I am using JDBC API.
The expression in the WHERE clause of this query is only one of the many such expressions in the WHERE clause of my actual query where I'm facing this problem.
Can somebody please help?
Thanks in advance,
Anchal.
I have a problem related to passing a number of parameters (the number changes dynamically) for the IN operator in the WHERE clause of a select statement. I want to have a static query e.g. "select * from emp where emp_name in (?, ?, ?, ....)". Here the number of place holders are known only at runtime which would depend on the number of employee names in the list chosen by the user. The list e.g. is:
String emp_names = "'A', 'B', 'C', 'D'";
I want to keep the query static but at the same time be able to provide N number of parameters to this query at run time. Even better if there is a workaround to having N number of placeholders. Having too many placeholders in the query doesn't look like a good idea. I am using JDBC API.
The expression in the WHERE clause of this query is only one of the many such expressions in the WHERE clause of my actual query where I'm facing this problem.
Can somebody please help?
Thanks in advance,
Anchal.