GetTrans

Description

Gets the values for the DataWindow control or DataStore object’s internal transaction object and stores these values in the programmer-specified transaction object.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataWindowChild object, DataStore object

Syntax

PowerBuilder

integer dwcontrol.GetTrans ( transaction transaction )

Argument

Description

dwcontrol

A reference to a DataWindow control, DataStore, or child DataWindow

transaction

The name of the transaction object into which you want to put the values

Returns

Returns 1 if it succeeds and –1 if an error occurs. The return value is usually not used.

If any argument value is null, the method returns null.

Usage

The SetTrans method (not the SetTransObject method) sets the internal transaction object. If you have not called SetTrans, GetTrans will fail.

Use GetTrans when you want to get the values for the transaction object in order to modify them, as shown in the last example.

If you are using SetTransObject, which specifies transaction information using a programmer-specified transaction object, GetTrans will not report information about the programmer-specified transaction object currently in effect. (SetTransObject is the recommended connection method because it gives better application performance. See SetTrans and SetTransObject for more information.)

Examples

Example 1

This example puts the values in the internal transaction object for dw_employee into the programmer-specified transaction object named object1:

transaction object1

object1 = CREATE transaction

dw_employee.GetTrans(object1)

Example 2

The following statement puts the values in the internal transaction object for dw_employee into the default transaction object (SQLCA):

dw_employee.GetTrans(SQLCA)

Example 3

The following statements change the database type and password of dw_employee. The first two statements create the transaction object emp_TransObj. The next two statements use the SetTrans method to set the values of SQLCA, and then use the GetTrans method to store the values of the current transaction object for dw_employee in emp_TransObj. The last two statements change the database type and password, and then the SetTrans method puts the revised values in the transaction object for dw_employee:

// Name the transaction object.

transaction emp_TransObj


// Create the transaction object.

emp_TransObj = CREATE transaction


// Set the internal transaction object.

dw_employee.SetTrans(SQLCA)


// Fill the new transaction object with original

// values from SQLCA.

dw_employee.GetTrans(emp_TransObj)


// Put revised values into the new transaction

// object.

// Change the database type.

emp_TransObj.DBMS = "Sybase"


// Change the password.

emp_TransObj.LogPass = "cam2"


// Associate the new transaction object with

// dw_employee, replacing SQLCA.

dw_employee.SetTrans(emp_TransObj)

See also