INF: Branching Within Static Batch in Embedded SQL for COBOLLast reviewed: November 7, 1997Article ID: Q66751 |
|
The information in this article applies to:
- Microsoft Embedded SQL version 4.2 for COBOL 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 = "Frog")
begin
delete
from authors
where au_lname = "Frog"
end
else
begin
insert into authors values("123-45-6789","Frog","Kermit",
"206 555-1212","Sesame Street","Redmond","WA","98052",1)
end
select @looper = @looper + 1
end
END-EXEC
if sqlcode not = 0
perform sql-error
end-if
stop run.
sql-error.
display "SQL error SQLCODE=" sqlcode.
|
Additional query words:
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |