INQUIRE_SQL Example
Execute some database statements, and handle errors by displaying the message and aborting the transaction.
exec sql whenever sqlerror goto err_handle;
exec sql select name, sal
into :name, :sal
from employee
where eno = :eno;
if name = 'Badman' then
exec sql delete from employee where eno = :eno;
else if name = 'Goodman' then
exec sql update employee set sal = sal + 3000
where eno = :eno;
end if;
exec sql commit;
...
err_handle:
exec sql whenever sqlerror continue;
exec sql inquire_sql (:err_msg = errortext);
print 'Enterprise Access product error: ',
sqlca.sqlcode;
print err_msg;
exec sql rollback;
end if;
Last modified date: 08/28/2024