Execute-Statement
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.ExecuteSQL(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 | [] | SQL statement parameter, SQL statement placeholder. MySQL and SQLServer is %s, Sqlite3 is ?, and Oracle is :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.ExecuteSQL(objDatabase ,sql, {"args": ["test2", 12, 2, 2]})
TracePrint(iRet)
// 1