How to Determine the Number of Affected Rows
The SQLCA variable sqlerrd(2) indicates how many rows were affected by the last row-affecting statement. Note that this variable is referenced by sqlerrd(2) rather than sqlerrd(3) as in other languages, because BASIC allocates sqlerrd elements 0 through 5.
The following program fragment, which deletes all employees whose employee numbers are greater than a given number, demonstrates how to use sqlerrd:
sub delete_rows(integer lower_bound_num)
exec sql include sqlca
exec sql begin declare section
declare integer low_eno
exec sql end declare section
! Use Embedded SQL variable in DELETE statement
low_eno = lower_bound_num
exec sql delete from employee &
where eno :low_eno
! Print the number of employees deleted
print sqlerrd(2), 'row(s) were deleted.'
end sub ! Delete_Rows