logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

rollback-transaction - (database)

Description

rollback-transaction will roll back a transaction started with begin-transaction. <options> (in "options" clause) is any additional options to send to database you wish to supply for this functionality. Once you start a transaction with begin-transaction, you must either commit it with commit-transaction or rollback with rollback-transaction. If you do neither, your transaction will be rolled back once the request has completed and your program will stop with an error message. This is because opening a transaction and leaving without committing or a rollback is a bug in your program. You must use begin-transaction, commit-transaction and rollback-transaction instead of calling this functionality through run-query. DATABASE <database> is specified in "@" clause and is the name of the database-config-file. If omitted, your program must use exactly one database (see --db option in gg). ERRORHANDLING The error code is available in <error> variable in "error" clause - this code is always "0" if successful. The <error> code may or may not be a number but is always returned as a string value. In case of error, error text is available in "error-text" clause in <error text> string. "on-error-continue" clause specifies that request processing will continue in case of an error, whereas "on-error-exit" clause specifies that it will exit. This setting overrides database-level db-error for this specific statement only. If you use "on-error-continue", be sure to check the error code. Note that if database connection was lost, and could not be reestablished, the request will error out (see error-handling).

Examples

begin-transaction @mydb run-query @mydb="insert into employee (name, dateOfHire) values ('Terry', now())" run-query @mydb="insert into payroll (name, salary) values ('Terry', 100000)" rollback-transaction @mydb

Name

rollback-transaction - (database)

Purpose

Rollbacks a SQL transaction.

See Also

Database begin-transactioncommit-transactioncurrent-rowdatabase-config-filedb-errormariadb-databasepostgresql-databaserollback-transactionrun-querysqlite-database See all documentation $DATE $VERSION GOLF(2gg)

Syntax

rollback-transaction [ @<database> ] \ [ on-error-continue | on-error-exit ] \ [ error <error> ] [ error-text <error text> ] \ [ options <options> ]

See Also