I'm new to programming and I was wonder how I would declare a variable I can use through out my code.
What I want to achieve is :
Myvariable = (select Column from table1 where column =1234 group by column);
select column from table2 where column in (myvariable);
select column from table3 where column in (myvariable);
and etc
Thanks in advance :)
If you're using PL/SQL Developer to access an Oracle database you can create a Test window (File - New - Test Window) with code similar to the following:
DECLARE
myVariable TABLE1.COLUMN%TYPE := 1234;
BEGIN
FOR aRow2 IN (SELECT COLUMN
FROM TABLE2
WHERE COLUMN = myVariable)
LOOP
DBMS_OUPUT.PUT_LINE('Do something with ''aRow2''');
END LOOP;
COMMIT;
FOR aRow3 IN (SELECT COLUMN
FROM TABLE3
WHERE COLUMN = myVariable)
LOOP
DBMS_OUPUT.PUT_LINE('Do something with ''aRow3''');
END LOOP;
COMMIT;
END;
You'll need to edit the above to do whatever you want with the rows from TABLE2 and TABLE3.
Best of luck.