Working with Savepoints
From InterBase
Go Up to Ending Transactions
Savepoints are implemented in stored procedures and triggers.
The InterBase API supports savepoints with the following functions:
To create a savepoint:
ISC_STATUS isc_start_savepoint(
ISC_STATUS *status_vector,
isc_tr_handle *trans_handle,
char *savepoint_name);
To release a savepoint:
ISC_STATUS isc_release_savepoint(
ISC_STATUS *status_vector,
isc_tr_handle *trans_handle,
char *savepoint_name);
To roll back to a savepoint:
ISC_STATUS isc_rollback_savepoint(
ISC_STATUS *status_vector,
isc_tr_handle *trans_handle,
char *savepoint_name
short option);
A SAVEPOINT Example
The following code sample is a simple example of how to use savepoints:
CREATE PROCEDURE add_emp_proj2 (emp_no SMALLINT, emp_name VARCHAR(20), proj_id CHAR(5)) AS
BEGIN
BEGIN
SAVEPOINT EMP_PROJ_INSERT;
INSERT INTO employee_project (emp_no, proj_id) VALUES (:emp_no,:proj_id);
WHEN SQLCODE -530 DO
BEGIN
ROLLBACK TO SAVEPOINT EMP_PROJ_INSERT;
EXCEPTION unknown_emp_id;
END
END
SUSPEND;
END;