Since most applications communicate with only one database, PowerBuilder provides a global default Transaction object called SQLCA (SQL Communications Area).
PowerBuilder creates the Transaction object before the application’s Open event script executes. You can use PowerScript dot notation to reference the Transaction object in any script in your application.
You can create additional Transaction objects as you need them (such as when you are using multiple database connections at the same time). But in most cases, SQLCA is the only Transaction object you need.
This simple example uses the default Transaction object SQLCA to connect to and disconnect from an ODBC data source named Sample:
// Set the default Transaction object properties.
SQLCA.DBMS="ODBC"
SQLCA.DBParm="ConnectString='DSN=Sample'"
// Connect to the database.
CONNECT USING SQLCA;
IF SQLCA.SQLCode < 0 THEN &
MessageBox("Connect Error", SQLCA.SQLErrText,&
Exclamation!)
...
// Disconnect from the database.
DISCONNECT USING SQLCA;
IF SQLCA.SQLCode < 0 THEN &
MessageBox("Disconnect Error", SQLCA.SQLErrText,&
Exclamation!)