Syntax 1Using values from an external transaction object – PB Docs 126

Syntax 1Using values from an external transaction object


Sets the values in the internal transaction object for a DataWindow
control or DataStore to the values from the specified transaction
object. The transaction object supplies connection settings, such
as the database name.


DataWindow type

Method applies to


DataWindow control, DataWindowChild object, DataStore






A reference to a DataWindow control,
DataStore, or child DataWindow in which you want to set the values
of the internal transaction object


The name of the transaction object from
which you want dwcontrol to get values

Return Values

Returns 1 if it succeeds and –1 if an error occurs.
If any argument’s value is null, the method returns null.


In most cases, use the SetTransObject method
to specify the transaction object. It is more efficient and allows
you to control when changes get committed to the database.

SetTrans copies the values from a specified
transaction object to the internal transaction object for the DataWindow
control or DataStore. When you use SetTrans in
a script, the DataWindow uses its internal transaction object and
automatically connects and disconnects as needed; any errors that
occur cause an automatic rollback. With SetTrans,
you do not specify SQL statements,
The DataWindow control connects and disconnects after each Retrieve or Update function.

If you use SetTrans for an EAServer component, you must
not set the UseContext Object database parameter to Yes.

note.png Use SetTransObject with composite DataWindows

You must use SetTransObject with
DataWindow objects that use the Composite presentation style. Composite
DataWindows are containers for other DataWindow objects and do not
have any internal transaction information of their own.

If you use SetTrans with each nested DataWindow
in a composite DataWindow, disconnect does not occur until the PowerBuilder
session ends.

Use SetTrans when you want PowerBuilder
to manage the database connections automatically because you have
a limited number of available connections or expect to use the application
from a remote location. SetTrans is appropriate
when you are only retrieving data and do not need to hold database
locks on records the user is modifying. For better performance,
however, you should use SetTransObject.


DBMS connection settings

You must set the parameters required to connect to your DBMS
in the transaction object before you can use the transaction object
to set the DataWindow’s internal transaction object and connect
to the database.

Updating more than one table

When you use SetTrans to specify the transaction
object, you cannot update multiple DataWindow objects or multiple
tables within one object.


This statement sets the values in the internal transaction
object for dw_employee to the values in the default transaction
object SQLCA:

The following statements change the database type
and password of dw_employee. The first two statements create
the transaction object emp_TransObj. The next statement
uses the GetTrans method to store the values of the internal transaction
object for dw_employee in emp_TransObj. The next
two statements change the database type and password. The SetTrans
method assigns the revised values to dw_employee:

See Also

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x