Cicode Programming Reference > Cicode Function Categories > SQL Functions Introduction > SQLCommit

SQLCommit

Commits (to the database) all changes made within a transaction. If you call the SQLBeginTrans() function to begin a transaction, you need to call the SQLCommit() function to save the changes you make to the database during that transaction (with the Insert, Delete, and Update SQL commands).

The SQLCommit() and SQLRollBack() functions both complete a transaction and release all database locks. But while the SQLCommit() function saves all changes made during the transaction, the SQLRollBack() function discards these changes. Unless you call the SQLCommit() function before you disconnect the database, CitectSCADA automatically rolls back the transaction any changes you made to the database in that transaction are discarded.

The SQLCommit() function could affect different databases in different ways. If the function is not performing as you expect, check that your database is ODBC compatible. Refer to the documentation for your database for information on committing transactions.

Syntax

SQLCommit(hSQL)

hSQL:

The handle to the SQL connection, returned from the SQLConnect() function. The SQL connection handle identifies the table where details of the associated SQL connection are stored.

Return Value

0 (zero) if successful, otherwise an error number is returned. (For details of the 307 error code, call the SQLErrMsg() function).

Related Functions

SQLBeginTran, SQLConnect, SQLDisconnect, SQLEnd, SQLErrMsg, SQLExec, SQLFieldInfo, SQLGetField, SQLInfo, SQLNext, SQLNoFields, SQLNumChange, SQLRollBack, SQLTraceOff, SQLTraceOn

Example

See SQLBeginTran

See Also

SQL Functions