The following example shows the code that DB/Assist generates for a multi-row SELECT statement named SelectStaffID in a SAM named ADMIN.
The sample code for the SelectStafflD statement includes the following ESL action routines, in this order:
•OPEN_SelectStaffID
•FETCH_SelectStaffID
•CLOSE SelectStaffID
action OPEN_SelectStaffID is
########################################################################
# DO NOT MODIFY THE DB/Assist GENERATED CODE BELOW
# SAM:ADMIN STMT:SelectStaffID 7/22/93 11:12:12
# DECLARE SQL_CUR_1 CURSOR FOR SELECT STAFF.ID, STAFF.NAME, STAFF.DEPT,
# STAFF.JOB, STAFF.YEARS, STAFF.SALARY, STAFF.COMM
# FROM DB2ADMIN.STAFF STAFF
# WHERE STAFF.ID = :ID_IV
#########################################################################
call EDB2Start(ADMINProgramID, Esqlca)
copy EDB2Allocate( 1, 1, 1) to EDB2RtnCode_IV
copy EDB2SetVariable(1, 0, 496, 4, ID_IV, EDB2NULL_IV) to EDB2RtnCode_IV
copy EDB2Call(26, 1, 1, 0) to EDB2RtnCode_IV
if (Esqlca.Sqlcode < 0 ) then
copy true to EDB2Error_BV
call EDB2Stop()
action EDB2WheneverError
else
copy false to EDB2Error_BV
end if
call EDB2Stop()
action FETCH_SelectStaffID is
########################################################################
# DO NOT MODIFY THE DB/Assist GENERATED CODE BELOW
# SAM:ADMIN STMT:SelectStaffID 7/22/93 11:12:12
# FETCH SQL_CUR_1 INTO :ID_IV, :NAME_SV:NAME_NIV, :DEPT_IV:DEPT_NIV,
# :JOB_SV:JOB_NIV, :YEARS_IV:YEARS_NIV, :SALARY_FV:SALARY_NIV,
# :COMM_FV:COMM_NIV
########################################################################
call EDB2Start(ADMINProgramID, Esqlca)
copy EDB2Allocate( 2, 7, 1) to EDB2RtnCode_IV
copy EDB2SetVariable(2, 0, 496, 4, ID_IV, EDB2NULL_IV) to EDB2RtnCode_IV
copy EDB2SetVariable(2, 1, 448, 9, NAME_SV, NAME_NIV) to EDB2RtnCode_IV
copy EDB2SetVariable(2, 2, 496, 4, DEPT_IV, DEPT_NIV) to EDB2RtnCode_IV
copy EDB2SetVariable(2, 3, 448, 5, JOB_SV, JOB_NIV) to EDB2RtnCode_IV
copy EDB2SetVariable(2, 4, 496, 4, YEARS_IV, YEARS_NIV) to EDB2RtnCode_IV
copy EDB2SetVariable(2, 5, 480, 8, SALARY_FV, SALARY_NIV) to EDB2RtnCode_IV
copy EDB2SetVariable(2, 6, 480, 8, COMM_FV, COMM_NIV) to EDB2RtnCode_IV
copy EDB2Call(25, 1, 0, 2) to EDB2RtnCode_IV
if (Esqlca.Sqlcode < 0 ) then
copy true to EDB2Error_BV
call EDB2Stop()
action EDB2WheneverError
else
copy false to EDB2Error_BV
end if
call EDB2Stop()
action CLOSE_SelectStaffID is
########################################################################
# DO NOT MODIFY THE DB/Assist GENERATED CODE BELOW
# SAM:ADMIN STMT:SelectStaffID 7/22/93 11:12:12
# CLOSE SQL_CUR_1
########################################################################
call EDB2Start(ADMINProgramID, Esqlca)
copy EDB2Call(20, 1, 0, 0) to EDB2RtnCode_IV
if (Esqlca.Sqlcode < 0 ) then
copy true to EDB2Error_BV
call EDB2Stop()
action EDB2WheneverError
else
copy false to EDB2Error_BV
end if
call EDB2Stop()