DatabaseLink`
DatabaseLink`
SQLUpdate
Details and Options
- To use SQLUpdate, you first need to load DatabaseLink using Needs["DatabaseLink`"].
- Returns an integer specifying the number of rows affected by the query.
- The following option can be given:
-
"Timeout" $SQLTimeout the timeout for the query
Examples
Basic Examples (1)
Needs["DatabaseLink`"]If you find that the examples in this section do not work as shown, you may need to install or restore the example database with the "DatabaseLink`DatabaseExamples`" package, as described in Using the Example Databases.
conn = OpenSQLConnection["demo"];Create a table and insert some data:
SQLCreateTable[conn, SQLTable["TEST"],
{
SQLColumn["COL1", "DataTypeName" -> "INTEGER"],
SQLColumn["COL2", "DataTypeName" -> "DOUBLE"]
}];SQLInsert[conn, "TEST", {"COL1", "COL2"}, {10, 10.5}];SQLSelect[conn, "TEST"]SQLUpdate[conn, "TEST", {"COL1", "COL2"}, {12, 12.5}]SQLSelect[conn, "TEST"]SQLInsert[conn, "TEST", {"COL1", "COL2"}, {20, 20.5}];SQLSelect[conn, "TEST"]Update only data matching a condition:
SQLUpdate[conn, "TEST", {"COL1", "COL2"}, {4, 1.1}, SQLColumn["COL1"] < 15 ]SQLSelect[conn, "TEST"]SQLDropTable[conn, "TEST"];CloseSQLConnection[conn];