sa_check_commit system procedure

Checks for outstanding referential integrity violations before a commit.

Syntax
sa_check_commit( 
tname, 
keyname 
)
Arguments
  • tname   A VARCHAR(128) parameter containing the name of a table with a row that is currently violating referential integrity.

  • keyname   A VARCHAR(128) parameter containing the name of the corresponding foreign key index.

Remarks

If the database option wait_for_commit is On, or if a foreign key is defined using CHECK ON COMMIT in the CREATE TABLE statement, you can update the database and cause a referential integrity violation if the violations are resolved before the changes are committed.

You can use the sa_check_commit system procedure to check whether there are any outstanding referential integrity violations before attempting to commit your changes.

The returned parameters indicate the name of a table containing a row that is currently violating referential integrity, and the name of the corresponding foreign key index.

Permissions

None

Side effects

None

See also
Example

The following set of commands can be executed from Interactive SQL. Rows are deleted from the Departments table in the sample database and a referential integrity violation occurs. The call to the sa_check_commit system procedure checks which tables and keys have outstanding violations, and the rollback cancels the change:

SET TEMPORARY OPTION wait_for_commit='On'
go
DELETE FROM Departments
go
CREATE VARIABLE tname VARCHAR( 128 );
CREATE VARIABLE keyname VARCHAR( 128 )
go
CALL sa_check_commit( tname, keyname )
go
SELECT tname, keyname
go
ROLLBACK
go