Skip to main content

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

ParameterRequiredTypeDefaultDescription
objDatabaseTrueexpressionobjDatabaseDatabase object, a database object created using the Create Database Object command (Database.CreateDB)
sqlTruestring""Add/remove/modify a SQL statement
argsNoneexpression[]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