How to Determine the Number of Affected Rows
The third element of the SQLCA array sqlerrd indicates how many rows were affected by the last row-affecting statement. This element is referenced by sqlerrd[2] rather than sqlerrd[3] as in other languages, because C subscripts begin at number 0.
The following program fragment, which deletes all employees whose employee numbers are greater than a given number, demonstrates how to use sqlerrd.
Example: sqlerrd usage
exec sql include sqlca;
Delete_Rows(lower_bound)
int lower_bound;
{
exec sql begin declare section;
int lower_bound_num = lower_bound;
exec sql end declare section;
exec sql delete from employee
where eno > :lower_bound_num;
/* Print the number of employees deleted */
printf("%d row(s) were deleted.\n",
sqlca.sqlerrd[2]);
}