Fetch multiple columns from cursor

Database
N/A

Fetch multiple columns from cursor

Hi,

I am try to use a cursor to loop through multiple values, which is fine if I only use one column.

It doesn't seem to work if I try to fetch more than one column.

e.g.

DECLARE var_a VARCHAR(10);

DECLARE var_b VARCHAR(10);

DECLARE var_c VARCHAR(10);

DECLARE crsr CURSOR FOR

SELECT col_a, col_b, col_c FROM schema.mytable;

OPEN crsr FETCH NEXT FROM crsr INTO var_a, var_b, var_c;

WHILE (SQLCODE = 0) DO

BEGIN ...

Does anyone know why?

Tags (2)