DbBeginTrans - method of the PmaAdo object

Starts new transaction over the connected database.
Object DbBeginTrans([String sParams])
sParams[optional] (String) Additional parameters of the DbBeginTrans method. Entries are in the KeyVal format, for example "return:map;".
"return:xxx;" (optional) - Specifies whether the method return values is a map containing multiple values (new procedure) or a single value (old procedure).
If not set, then the old procedure is used.
map - Returns a map (PmMap object) containing multiple returned values (new procedure) (e.g. Result, AffectedRows, ErrorCode, ErrorText).
Return values:
New procedure: Returns PmMap object with values in following items:
- "Result": empty value (the method does not return anything)
- "ErrorCode": numeric error code where the 0 value means successful method execution (no error)
- "ErrorText": error text description

Old procedure: Returns empty value (the method does not return anything).
The DbBeginTrans method starts a new transaction over the connected database. All following operations over this database will be confirmed as complete transaction by the DbCommitTrans method or cancelled by the DbRollbackTrans method. Transactions must be supported by both the connected database and the provider.
See also:
JavaScriptVBScriptSelect and copy to clipboard

var val = oDb.DbBeginTrans();
Adds new record into tables table1 and table2 using transaction. If adding the record to any of the tables fails, then all operations from beginning of the transaction are cancelled. It means that both records are added or no record is added. The failure of the operation can be detected in the PmaAdo object by means of the LastErr property.
JavaScriptVBScriptSelect and copy to clipboard

var oDb = pMe.Pm("/TestAdoDb");
var nLastErr1, nLastErr2;

if (0 == oDb.DbBeginTrans("return:map;").ErrorCode)
nLastErr1 = oDb.DbExecute("", "INSERT table1 (name, value) VALUES ('pi', 3.14)", "return:map;").ErrorCode;
nLastErr2 = oDb.DbExecute("", "INSERT table2 (name, value) VALUES ('pi', 3.14)", "return:map;").ErrorCode;
if (0 == nLastErr1 && 0 == nLastErr2)

Pm8.03.09: Created
Pm8.03.22: Returns the PmMap object with values in items "Result", "ErrorCode" and "ErrorText".
PROMOTIC 9.0.25 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.