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 2 3 4 5 6 7 8 9 10 11 12 13 14 |
// 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!) |
Semicolons are SQL statement 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.