File: commit-transaction.2gg

package info (click to toggle)
golf 601.4.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,824 kB
  • sloc: ansic: 20,020; sh: 1,171; makefile: 292
file content (72 lines) | stat: -rw-r--r-- 2,616 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
commit-transaction \-  (database)
.SH PURPOSE
Commits a database transaction.

.SH SYNTAX

.RS 4
.EX

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

.EE
.RE

.SH DESCRIPTION
Database transaction started with \fBbegin-transaction\fP is committed with commit-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 \fBbegin-transaction\fP, you must either commit it with \fBcommit-transaction\fP or rollback with \fBrollback-transaction\fP. If you do neither, your transaction will be rolled back once the \fBrequest\fP 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 \fBrun-query\fP.

.LP
.B DATABASE
.LP

<database> is specified in "@" clause and is the name of the \fBdatabase-config-file\fP. If omitted, your program must use exactly one database (see --db option in \fBgg\fP).

.LP
.B ERROR HANDLING
.LP

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 \fBrequest\fP processing will continue in case of an error, whereas "on-error-exit" clause specifies that it will exit. This setting overrides database-level \fBdb-error\fP 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 \fBerror-handling\fP).

.SH EXAMPLES

.RS 4
.EX

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)" 
commit-transaction @mydb

.EE
.RE

.SH SEE ALSO
 Database

\fBbegin-transaction\fP  
\fBcommit-transaction\fP  
\fBcurrent-row\fP  
\fBdatabase-config-file\fP  
\fBdb-error\fP  
\fBmariadb-database\fP  
\fBpostgresql-database\fP  
\fBrollback-transaction\fP  
\fBrun-query\fP  
\fBsqlite-database\fP   
See all 
\fBdocumentation\fP