GOLF(2gg)
β¨ GOLF(2gg) β¨
okay bestie, gather round, because we're about to talk about commit-transaction from the 2gg manual and honestly? it's giving β¨closureβ¨. π
π NAME π
commit-transaction β it's a database thing, fr fr ποΈ
π PURPOSE π
It commits a database transaction. that's it, that's the whole job, and it does it flawlessly π
πΈ SYNTAX πΈ
commit-transaction [ @<database> ] \
[ on-error-continue | on-error-exit ] \
[ error <error> ] [ error-text <error text> ] \
[ options <options> ]
π¦ DESCRIPTION π¦
So here's the tea, bestie. π A database transaction that you started with begin-transaction? You commit it with commit-transaction. That's the whole vibe. One starts it, the other seals the deal. iconic.
The <options> (the one living in the options clause) is literally any additional options you want to send to the database β whatever extra stuff you feel like supplying for this functionality. your call, your rules π«Ά
Now, the important part, and I need you to lock in π: 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 gets rolled back once the request has completed, AND your program will stop with an error message. why? because opening a transaction and then leaving without committing or rolling back is a bug in your program. not a vibe. not the move. do not do this. π
Also, and this is non-negotiable: you must use begin-transaction, commit-transaction and rollback-transaction instead of calling this functionality through run-query. like, that's the rule. periodt. π
ποΈ DATABASE ποΈ
<database> gets specified in the "@" clause, and it's the name of the database-config-file. If you omit it, your program must use exactly one database (peep the --db option in gg for that). one db, no confusion, slay β¨
π ERROR HANDLING π
The error code lives in the <error> variable in the "error" clause β and this code is always "0" if everything's successful. π The <error> code may or may not be a number, but it's always returned as a string value, just so you know. And in case of an error, the error text is available in the "error-text" clause in the <error text> string. got it? got it. π
The "on-error-continue" clause says request processing will continue in case of an error, whereas the "on-error-exit" clause says it will exit. This setting overrides database-level db-error for this specific statement only. and listen β if you use "on-error-continue", be sure to check the error code. like, actually check it. don't just skip past it π
Heads up bestie: if the database connection was lost, and could not be reestablished, the request will error out (see error-handling). no cap. π₯
π 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)"
commit-transaction @mydb
look at that. Terry got hired AND got paid, and it all committed together. main character energy honestly π
β SEE ALSO β
Database
begin-transaction commit-transaction current-row database-config-file db-error mariadb-database postgresql-database rollback-transaction run-query sqlite-database See all documentation
and that's the whole page, bestie π§π this was the GOLF(2gg) manual, version $VERSION, dated $DATE β go forth and commit your transactions, and remember: never leave one hanging. that's a bug and you're better than that. byeee πβ¨π
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms