If i have a query that is similar to the one shown below
select first_name, author, location
from author_details
where first_name=?
The ? value is populated on the Java side using
statement = getConnection().prepareStatement(MY_QUERY);
statement.setString(1, name);
I want to update the query for an additional check in the where clause:
select first_name, author, location
from author_details
where first_name=? or last_name=?
I want to use the same value that is passed in as the 'name' from the java code. Is it possible to use the same passed in value to check both the first_name and last_name or do i have to add another statement.setString(2, name) entry on the java code?
I know within SQLPlus i can declare a variable and use it later but im not sure how to do the same on an sql query executed through JDBC