the sqlca is used in a stored procedure as in any other program:
/* this is a stored procedure for test purpose */
dbsp03: proc (parm1) options(main noexecops);
dcl h bin fixed(31) init (123);
exec sql include sqlca;
exec sql delete from my.table where col > :h ;
if sqlca.sqlcode ^= 0 & sqlca.sqlcode ^= 100 then do;
call your_error_routine();
end;
put skip edit ('----------- DBSP03 (REPORT) ----------') (A);
put skip edit (' Number of records deleted: ', SQLCA.SQLERRD(3) ) (A,A);
put skip edit ('----------- DBSP03 (REPORT END) -------') (A);
end dbsp03 ;
Note: The number of records affected by the statement is stored in the variable SQLERRD(3), not -as dbzTHEdinosaur mentioned- in SQLERRCD(3)
if your program language is C, the number is stored in sqlerrd[2]