Q: Where is the transaction object?
A: It is one of the most important objects in PowerBuilder and the most incomprehensible objects. It is actually a structure variable that transmits information between the PowerBuilder program and the database. There are 15 members in total.
[Note] 15 members of the transaction object
Serial number |
Name |
Type |
Description |
1 |
DBMS |
String |
The name of the database management system used, such as Sybase, Oracle, and ODBC. |
2 |
Database |
String |
Name of the database to be connected. |
3 |
Userid |
String |
The username used to connect to the database. Some DBMS do not need this option. |
4 |
Dbpass |
String |
Password used to connect to the database. |
5 |
Lock |
String |
This is the protection level of the database, which is generally not required. |
6 |
Logid |
String |
The username used to log on to the database server. Some DBMS do not need this option, but Sybase and Oracle need to specify this parameter. |
7 |
Logpass |
String |
The user password used to log on to the database server. This attribute can be set but cannot be set, but Sybase and Oracle need to specify a password. |
8 |
Servername |
String |
Database Server name. |
9 |
Autocommit |
Boolean |
Specifies whether to set the database to automatically submit all transactions. The default value is false. That is to say, you must manage transactions in the application and commit transactions to the database as appropriate. If true is selected, each transaction is automatically committed by the system. |
10 |
Dbparm |
String |
The attribute used to pass special information to the database. |
11 |
Sqlcode |
Long |
Indicates that the last SQL operation failed or succeeded. The value is as follows: |
Returned results |
0 |
No error. |
-1 |
An error occurs. |
100 |
No data is retrieved. |
12 |
Sqlnrows |
Long |
The number of rows affected by the last SQL operation. The database has different meanings. |
13 |
Sqldbcode |
Long |
Database Error code. Different databases have different meanings. |
14 |
Sqlerrtext |
String |
The text description corresponding to the error code in the sqldbcode attribute. |
15 |
Sqlreturndata |
String |
Return the additional information about the SQL statement executed by the DBMS. Different DBMS values are different. |
Example: this is an example of the Code required to connect to the Sybase Database:
Sqlca. dbms = "Sybase"
Sqlca. database = "testdatabase"
Sqlca. logid = "lihongwei"
Sqlca. logpass = "lag"
Sqlca. servername = "jhc_server"
Sqlca. autocommit = false
This is an example of the Code required to connect to an ODBC database (such as Sybase SQLAnywhere 5.0:
Sqlca. dbms = "odbc"
Sqlca. dbparm = "connectstring = 'dsn = testdatabase '"