From: Ewa Bartosiewicz on
I need to make a cursor from a query, but I don't know how many
columns the select will retrieve. That's why I can't put the values in
variables.

I have something like this:

SET query = 'SELECT DISTINCT ' || parameter_list || ', VAL FROM
TABLE ;

PREPARE stmt FROM query;
OPEN cursor;

first_loop:
LOOP
FETCH cursor INTO ?????, val

SET update = 'UPDATE TABLE2 SET VALUE = val
WHERE ??? = ??? AND ??? = ???;
EXECUTE IMMEDIATE update;
END LOOP first_loop;

Is there anything I can do with this?
Thanks!

Ewa
From: ChrisC on
Well, you could use the MERGE statement instead:

MERGE INTO TABLE2
USING TABLE
ON ??? = ??? AND ??? = ???
WHEN FOUND THEN UPDATE SET VALUE = val
ELSE IGNORE;

-Chris