omron — DBExecute

Appendix: Built-in Scripting Language Tip: To delete all rows in the table, make the condition statement a single space ( " " ). optStrErrorTag The name of a String tag that will receive detailed error messages, if errors occur during runtime. Note: The tag name must be enclosed in quotes, as shown in the syntax diagram, or else the project will try to get the value of the named tag. This is an optional parameter. Returned value Returns the number of rows deleted from the table. In case of error, returns a negative number. Examples As used in a Math worksheet: DBExecute DBExecute is a built-in scripting function that executes a custom SQL statement on an external database.

If the statement is a query (e.g., SELECT), then the database values are copied to specified array tags. Syntax DBExecute( strDBConn , strSQL { | , optStrTags , optNumMaxRows { | , optStrErrorTag } } ) strDBConn The name of the database connection. Connections are configured in the Database/ERP folder in the Project Explorer . strSQL A complete, syntactically correct SQL statement. Note: In SQL, curly brackets ( {} ) are typically used to enclose an expression that must be evaluated before the entire SQL statement is executed. For example:

SELECT * INTO inmates FROM OPENROWSET ('MSDASQL','Driver={Microsoft Text Driver (*.txt; *.csv)};DEFAULTDIR=C:\;Extensions=CSV;','SELECT * FROM flat.csv') In IWS, however, curly brackets are used to reference project tags in text fields that are not normally evaluated (e.g., in the caption of a Button object). If you pass a SQL statement that includes such an expression to DBExecute , then the project will try to evaluate the expression as a tag reference and the function will fail. To pass the SQL statement so that the project can correctly evaluate the expression, create a new string tag that contains the text of the expression and then reference that tag in the SQL statement. For example:

AuxTag = "{Microsoft Text Driver (*.txt; *.csv)}" Page 630 InduSoft Web Studio Tag Name Expression nRowsDeleted DBDelete( "DB1", "Table1", "Column1 > 1000", "TagError" ) // Deletes all rows in Table1 where the value of Column1 is greater than 1000. The returned value (i.e., the number of rows deleted) is written to TagError. Tag DBDelete( "DB1", "Table1", " " ) // Deletes all rows of Table1. Function Group Execution Windows Embedded Thin Client DBExecute Database/ERP Synchronous Supported Supported Supported