home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
db22re.zip
/
DISPTB.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-03-10
|
3KB
|
91 lines
/*
┌──────────────────────────────────────────────────────────────────┐
│ Name : disptb.cmd │
│ Purpose : display the "sample staff" table │
│ Platform : DB2/2 │
│ Author : Jeff Fisher │
│ IBM Toronto Development Lab │
│ Disclaimer : This "sample" code is for demonstrations only, no │
│ warrenties are made or implied as to correct │
│ function. You should carefully test this code in │
│ your own environment before using it. │
│ │
└──────────────────────────────────────────────────────────────────┘
*/
Main:
call Start_Using
stmtbuf = 'select * from staff order by id'
call SQLEXEC 'PREPARE s1 FROM :stmtbuf'
if SQLCA.SQLCODE \= 0 then signal ErrorSQL
call SQLEXEC 'DECLARE c1 CURSOR FOR s1'
if SQLCA.SQLCODE \= 0 then signal ErrorSQL
call SQLEXEC 'OPEN c1'
if SQLCA.SQLCODE \= 0 then signal ErrorSQL
do until SQLCA.SQLCODE \=0
call SQLEXEC 'FETCH c1 INTO :id,',
':name :n_name,',
':dept :n_dept,',
':job :n_job,',
':years :n_years,',
':salary :n_salary,',
':comm :n_comm'
if SQLCA.SQLCODE = +100 then leave
if SQLCA.SQLCODE \= 0 then signal ErrorSQL
if n_name <0 then name = ' '
if n_dept <0 then dept = ' '
if n_job <0 then job = ' '
if n_years <0 then years = ' '
if n_salary <0 then salary = ' '
if n_comm <0 then comm = ' '
say '****************************'
say 'Identification: ' id
say ' Name: ' name
say ' Department: ' dept
say ' Job: ' job
say ' Years: ' years
say ' Salary: ' salary
say ' Commission: ' comm
say '****************************'
pause
end
EndProg:
call SQLEXEC 'CLOSE c1'
call Stop_Using
exit
ErrorSQL:
call beep 220,1000
say
say ' >>> SQL has returned a fatal condition code'
say ' SQLCODE = ' SQLCA.SQLCODE
say ' MSG = ' SQLMSG
say
pause
signal EndProg
Start_Using:
call SQLEXEC 'CONNECT TO SAMPLE IN SHARED MODE'
if SQLCA.SQLCODE \=0 then signal ErrorSQL
return
Stop_Using:
call SQLEXEC 'CONNECT RESET'
if SQLCA.SQLCODE \=0 then signal ErrorSQL
return