% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>
FS::Misc::Savepoint - Provides methods for SQL Savepoints
use FS::Misc::Savepoint;
# Only valid within a transaction
local $FS::UID::AutoCommit = 0;
savepoint_create( 'savepoint_label' );
my $error_msg = do_some_things();
if ( $error_msg ) {
savepoint_rollback_and_release( 'savepoint_label' );
} else {
savepoint_release( 'savepoint_label' );
}
Provides methods for SQL Savepoints
Using a savepoint allows for a partial roll-back of SQL statements without forcing a rollback of the entire enclosing transaction.
Executes SQL to create a savepoint named LABEL.
Savepoints cannot work while AutoCommit is enabled.
Savepoint labels must be valid sql identifiers. If your choice of label would not make a valid column name, it probably will not make a valid label.
Savepoint labels must be unique within the transaction.
Release the savepoint - preserves the SQL statements issued since the savepoint was created, but does not commit the transaction.
The savepoint label is freed for future use.
Roll back the savepoint - forgets all SQL statements issues since the savepoint was created, but does not commit or roll back the transaction.
The savepoint still exists. Additional statements may be executed, and savepoint_rollback called again.
Rollback and release the savepoint
Create %params from function input
Basic savepoint label validation
Complain when trying to use savepoints without disabling AutoCommit