4. Embedded SQL for Fortran : The SQL Communications Area : Error Handling Using the SQLCA : How to Determine the Number of Affected Rows
 
Share this page                  
How to Determine the Number of Affected Rows
The SQLCA variable sqlerr(3) indicates how many rows were affected by the last row-affecting statement. (Note that in the SQL Reference Guide, this field is called sqlerrd(3).) The following program fragment, which deletes all employees whose employee numbers are greater than a given number, demonstrates how to use sqlerr.
Example: sqlerr usage
      subroutine DelRow(lbnum)

          exec sql include sqlca
          exec sql begin declare section 
                     integer lbnum 
      exec sql end declare section
      exec sql delete from employee 
     1    where eno > :lbnum

C Print the number of employees deleted
          print *, sqlerr(3), 'row(s) were deleted.'
          end