The default Transaction object
SQLCA
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.
Example
This simple example uses the default Transaction object SQLCA to connect to and disconnect
from an ODBC data source named Sample:
1 |
// Set the default Transaction object properties. |
1 |
SQLCA.DBMS="ODBC" |
1 |
SQLCA.DBParm="ConnectString='DSN=Sample'" |
1 |
// Connect to the database. |
1 |
CONNECT USING SQLCA; |
1 |
IF SQLCA.SQLCode < 0 THEN & |
1 |
   MessageBox("Connect Error", SQLCA.SQLErrText,& |
1 |
   Exclamation!) |
1 |
... |
1 |
// Disconnect from the database. |
1 |
DISCONNECT USING SQLCA; |
1 |
IF SQLCA.SQLCode < 0 THEN & |
1 |
   MessageBox("Disconnect Error", SQLCA.SQLErrText,& |
1 |
      Exclamation!) |
terminators
When you use embedded SQL in
a PowerBuilder script, all SQL statements must
be terminated with a semicolon (;). You do not use
a continuation character for multiline SQL statements.