Batch-Execution-of-SQL-Statements
Command Description
Batch execution of SQL statements, and return the number of results affected (select statement does not support this yet). Set SQL statement placeholders based on SQL attributes: MySQL, SQLServer, PostgreSQL: %s, Sqlite3: ?, Oracle: 1
Command Prototype
iRet = Database.ExecuteBatchSQL(objDatabase ,sql, optionArgs)
Parameter Description
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
objDatabase | True | expression | objDatabase | Database object, a database object created using the Create Database Object command (Database.CreateDB) |
sql | True | string | "" | Add/remove/modify a SQL statement |
args | None | expression | [] | The SQL statement parameter. Traverse the two-dimensional array of the parameter and execute SQL statements in loops. For placeholder, MySQL and SQLServer uses %s. Sqlite3 uses ? and Oracle uses :1 |
return
iRet,The variable used to save the output of the command.
Demo
sql = "INSERT IGNORE INTO `test` (`name`, `age`, `aa`, `bb`) VALUES (%s, %s, %s, %s);"
iRet = Database.ExecuteBatchSQL(objDatabase ,sql, {"args": [["test3", 12, 2, 2], ["test4", 12, 2, 2]]})
TracePrint(iRet)
// 2