I found the following syntax diagram for a for loop:
Has anyone successfully used the cursor name clause. Whenever I try it I get a syntax error message.
Code:
>>-+---------+---FOR--for-loop-name--AS------------------------->
'-label:--'
>-----+--------------------------+--select-statement---DO------->
'-cursor-name--CURSOR FOR--'
.-------------------------------.
V |
>--------SQL-procedure-statement--;---+--END FOR----+--------+-><
'-label--'
Code:
begin atomic
declare commitcount integer default 1;
for row as cr cursor for select * from geniusdata.pm_policy_master
do
delete from geniusdata.pm_policy_master where current of cr;
if commitcount>=5000 then
commit;
set commitcount = 1;
else
set commitcount = commitcount + 1;
end if;
end for;
commit;
end
SQL0104N An unexpected token "cr cursor for" was found