I have some different SELECT queries with same values. I want to use something like DECLARE but when I write a simple DECLARE it says that "INTO" is expected.
If I want only a "SELECT", how can I use this form witout "INTO"?
Simply I have two (or more) selects:
SELECT * FROM my_table1 WHERE column1=5 and column2=6;
and
SELECT * FROM my_table2 WHERE col1=5 and col2=6;
Now I want to declare a variable like var_col1 and var_col2 and use them in both select queries at the same time.
I thought this would work:
DECLARE
var_col1 number := 5;
var_vol2 number := 6;
BEGIN
SELECT * FROM my_table1 WHERE column1=var_col1 and column2=var_col2;
SELECT * FROM my_table2 WHERE col1=var_col1 and col2=var_col1;
/* and more SELECTs with var_col1 and var_col2 */
END;
But no chance... How is the way to do that without a procedure or function?