次の方法で共有


SQLCOMMIT( ) Function

Commits a transaction.

SQLCOMMIT(nConnectionHandle)

Return Values

Numeric

Parameters

  • nConnectionHandle
    Specifies the connection handle to the data source returned by SQLCONNECT( ).

Remarks

Use SQLCOMMIT( ) to commit a transaction. SQLCOMMIT( ) returns 1 if the transaction is successfully committed; otherwise, it returns -1. If SQLCOMMIT( ) returns -1, you can use AERROR( ) to determine why the transaction could not be committed.

If manual transactions are in effect (the SQLSETPROP( ) Transactions property is set to Manual), you can send multiple updates to remote tables and commit all the updates with SQLCOMMIT( ).

Updates can be rolled back with SQLROLLBACK( ).

Example

The following example assumes SQLCONNECT( ) is successfully issued, and its return value is stored to a memory variable named gnConnHandle. SQLSETPROP( ) is used to set the Transactions property to 2 (Manual), allowing you to use SQLCOMMIT( ) and SQLROLLBACK( ).

The authors table is modified with SQLEXEC( ), and the changes to the table are committed with SQLCOMMIT( ).

= SQLSETPROP(gnConnHandle, 'Transactions', 2)  && Manual transactions
= SQLEXEC(gnConnHandle, "INSERT INTO authors (au_id, au_lname);
   VALUES ('aupoe', 'Poe')")  && Modify the authors table
= SQLCOMMIT(gnConnHandle)  && Commit the changes

See Also

AERROR( ) | BEGIN TRANSACTION | END TRANSACTION | SQLCONNECT( ) | SQLROLLBACK( ) | SQLSETPROP( )