List:MaxDB« Previous MessageNext Message »
From:Daniel Dittmar Date:July 30 2003 5:22pm
Subject:RE: nested while statements / nested loops
View as plain text  
> maybe someone can help me with my problem.
> I'm trying to chain more than one while-statement, but it won't work.
[...]
>    SELECT VAR1, VAR2 FROM TABLE1;
>     WHILE $rc = 0 DO BEGIN
>           FETCH INTO :var1, :var2;
>       SELECT VAR3 FROM TABLE2 WHERE VAR1 = :var1;
>         WHILE $rc = 0 DO BEGIN
>                FETCH INTO :var3;
>           insert into TABLE3 (a,b,c) Values (:var1, :var2, :var3);
>         END;
>     END;

If you want to iterate through more than one cursor at a time, you'll have to name them.
See DECLARE CURSOR on how to name them and FETCH <result_table_name> on how to
access them.

Daniel Dittmar

-- 
Daniel Dittmar
SAP DB, SAP Labs Berlin
daniel.dittmar@stripped
http://www.sapdb.org/

Thread
nested while statements / nested loopsAndreas Ackermann30 Jul
RE: nested while statements / nested loopsDaniel Dittmar30 Jul