Daniel Cernotto wrote:
>
> Hi,
>
> I have this problem:
>
> ----------------------
> DECLARE p_cursor CURSOR WITH HOLD FOR select x from table_1 FOR =
> UPDATE
>
> FOREACH p_cursor INTO variables
>
> SELECT * INTO variables_2 FROM table_2 WHERE variables ....>
> IF variables_2 THEN
>
> UPDATE table_1 SET y =3D 0 WHERE CURRENT OF p_cursor>
> END IF
>
> END FOREACH
> --------------------
>
> When I run this program, ERROR -266 occurs
>
> Anyone have any idea?
Hi,
imagine the following scenario:
FOREACH p_cursor INTO variables
-- If the first row is locked, for instance, you will
-- come here, but you do not have a "current row".
-- FOREACH terminates, if SQLNOTFOUND was found !!!
SELECT .....
-- The sqlca.sqlcode is reset to 0, if the SELECT was ok.
IF variable_2 THEN
-- here you just ask for variable_2, result from
-- the SELECT above.
UPDATE ...
-- would cause the error -266, because the FETCH
-- ( implicit fetch of the foreach ) returned an error.
END IF
END FOREACH
Okay ???
Bye
Stefan