INF: Branching Within Static Batch in Embedded SQL for COBOL
ID: Q66751
|
The information in this article applies to:
-
Microsoft Embedded SQL for COBOL, version 4.2
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.
Keywords : kbprg SSrvCobol SSrvProg
Version : 4.2
Platform : OS/2
Issue type :