Microsoft KB Archive/66751

= INF: Branching Within Static Batch in Embedded SQL for COBOL =

PSS ID Number: 66751

Article Last Modified on 2/4/2002

-

The information in this article applies to:


 * Microsoft Embedded SQL for COBOL 4.2

-



This article was previously published under Q66751



SUMMARY
One of the extra features available with Microsoft's Embedded SQL for COBOL that is not generally allowed in embedded SQL is the ability to branch and loop within a static SQL statement batch. The following code demonstrates this ability by inserting and deleting an author from the pubs..authors table five times:

WORKING-STORAGE SECTION. EXEC SQL INCLUDE SQLCA END-EXEC PROCEDURE DIVISION.

EXEC SQL declare @looper int select @looper = 1 while @looper < 11 begin if exists (select * from authors where au_lname = &quot;Frog&quot;) begin delete from authors where au_lname = &quot;Frog&quot; end else begin insert into authors values(&quot;123-45-6789&quot;,&quot;Frog&quot;,&quot;Kermit&quot;,         &quot;206 555-1212&quot;,&quot;Sesame Street&quot;,&quot;Redmond&quot;,&quot;WA&quot;,&quot;98052&quot;,1) end select @looper = @looper + 1 end END-EXEC if sqlcode not = 0 perform sql-error end-if stop run.

sql-error. display &quot;SQL error SQLCODE=&quot; sqlcode.

Keywords: kbProgramming KB66751

Technology: kbAudDeveloper kbSQLEmCOBOL kbSQLServSearch kbZNotKeyword3

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.