Hi guys,
I'm writing a basic SQL statement on Oracle 9i and I'm having a little trouble...basically I want to run an SQL query in which the WHERE clause re-uses an input parameter value which is entered by the user. However, I don't the user to have to re-type the parameter value for every instance the value is used.
Let me explain using an example...
If I have something like this:
SELECT * from myTable WHERE field1 = '&inputParam1' AND field2 = '&inputParam1';
If I run this the user is prompted TWICE to enter the value for &inputParam1; is there a way to tell the SQL to simply ask once for the &inputParam1 value and then re-use the value entered for every instance of &inputParam1??
I know I could write the SQL using a DECLARE, BEGIN and END format whereby I declare a variable such as "var_productInput := '&inputParam1';" but the users want to simply take the output and paste it in to Excel. If I use the DECLARE, BEGIN and END format I need to output the results using dbms_output.put_line(), right? I just need a single SQL statement.
I have tried using '&&inputParam1' instead of '&inputParam1' but this seems to bind the value entered for &&inputParam1 for the entire database session. The user is prompted once and then for every re-execution of the SQL the same &inputParam1 value is used.
I want the user to be able to run the SQL statement but be prompted for the &inputParam1 value ONCE for each execution...can anyone help me out here PLEASE??
Thanks guys