Movatterモバイル変換


[0]ホーム

URL:


November 13, 2025: PostgreSQL 18.1, 17.7, 16.11, 15.15, 14.20, and 13.23 Released!
DocumentationPostgreSQL devel (2025-12-17 20:34:52 - git commitab8af1db430)
Supported Versions:Current (18) /17 /16 /15 /14
Development Versions:devel
Unsupported versions:13 /12 /11
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for thecurrent version, or one of the other supported versions listed above instead.
42.10. Transaction Management
Prev UpChapter 42. PL/Tcl — Tcl Procedural LanguageHome Next

42.10. Transaction Management#

In a procedure called from the top level or an anonymous code block (DO command) called from the top level it is possible to control transactions. To commit the current transaction, call thecommit command. To roll back the current transaction, call therollback command. (Note that it is not possible to run the SQL commandsCOMMIT orROLLBACK viaspi_exec or similar. It has to be done using these functions.) After a transaction is ended, a new transaction is automatically started, so there is no separate command for that.

Here is an example:

CREATE PROCEDURE transaction_test1()LANGUAGE pltclAS $$for {set i 0} {$i < 10} {incr i} {    spi_exec "INSERT INTO test1 (a) VALUES ($i)"    if {$i % 2 == 0} {        commit    } else {        rollback    }}$$;CALL transaction_test1();

Transactions cannot be ended when an explicit subtransaction is active.


Prev Up Next
42.9. Explicit Subtransactions in PL/Tcl Home 42.11. PL/Tcl Configuration

[8]ページ先頭

©2009-2025 Movatter.jp