Transaction basics – PB Docs 125

Transaction basics

CONNECT and DISCONNECT

A successful CONNECT starts a transaction,
and a DISCONNECT terminates the transaction.
All SQL statements that execute
between the CONNECT and the DISCONNECT occur
within the transaction.

Before you issue a CONNECT statement, the
Transaction object must exist and you must assign values to all
Transaction object properties required to connect to your DBMS.

COMMIT and ROLLBACK

When a COMMIT executes, all changes to
the database since the start of the current transaction (or since
the last COMMIT or ROLLBACK)
are made permanent, and a new transaction is started. When a ROLLBACK executes,
all changes since the start of the current transaction are undone
and a new transaction is started.

When a transactional component is deployed to EAServer or another application
server, you can use the TransactionServer context object to control transactions.
See “Transaction server deployment”.

AutoCommit setting

You can issue a COMMIT or ROLLBACK only
if the AutoCommit property of the Transaction object is set to False (the
default) and you have not already started a transaction using embedded SQL.

For more about AutoCommit, see “Description of Transaction
object properties”
.

note.png Automatic COMMIT when disconnected

When a transaction is disconnected, PowerBuilder issues a COMMIT statement.

Transaction pooling

To optimize database processing, you can code your PowerBuilder
application to take advantage of transaction pooling.

For information, see “Pooling database transactions”.

Transaction server deployment

Components that you develop in PowerBuilder can participate
in transactions in EAServer or
other application servers. You can mark components to indicate that
they will provide transaction support. When a component provides transaction
support, the transaction server ensures that the component’s database
operations execute as part of a transaction and that the database changes
performed by the participating components are all committed or rolled back.
By defining components to use transactions, you can ensure that
all work performed by components that participate in a transaction
occurs as intended.

PowerBuilder provides a transaction service context object called TransactionServer
that gives you access to the transaction state primitives that influence
whether the transaction server commits or aborts the current transaction.
COM+ clients can also use the OleTxnObject object to control transactions.
If you use the TransactionServer context object and set the UseContextObject
DBParm parameter to Yes, COMMIT and ROLLBACK statements
called in the Transaction object will result in a database error.

By default, the TransactionServer context object is not used.
Instead you can use COMMIT and ROLLBACK statements
to manage transactions. In this case, COMMIT is
interpreted as a SetComplete function and ROLLBACK is
interpreted as a SetAbort function.

For information, see “Providing support for transactions”.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x