OK, Thank you. Actually this is in PL/SQL but the process logic should basically be the same.
I have a query as SELECT DISTINCT Field FROM Table a
I would like to set the value of parameter as follows
set Param = (SELECT DISTINCT Field FROM table a) -- mind you I only need the first record from this query
Param is then used in a series of other queries below.
INSERT INTO Table b
SELECT FIELD, FIELD, ... FROM Table c where Field = Param
UPDATE Table b
SET FIELD_Z = (SELECT FIELD_1 FROM Table d WHERE field_3 = Param
Once all of the query have been executed, I need to go back to STEP A and this time use the next record returned by the query in Step a.
The process is repeated until all the records in Step A query have been processed.