18.01.2015 Views

Technical Reference Manual - InduSoft

Technical Reference Manual - InduSoft

Technical Reference Manual - InduSoft

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Appendix: Built-in Scripting Language<br />

Note: In SQL, curly brackets ({}) are typically used to enclose an expression that<br />

must be evaluated before the entire SQL statement is executed. For example:<br />

SELECT * INTO inmates FROM OPENROWSET<br />

('MSDASQL','Driver={Microsoft Text Driver (*.txt;<br />

*.csv)};DEFAULTDIR=C:\;Extensions=CSV;','SELECT * FROM<br />

flat.csv')<br />

In IWS, however, curly brackets are used to reference project tags in text fields<br />

that are not normally evaluated (e.g., in the caption of a Button object). If you<br />

pass a SQL statement that includes such an expression to DBExecute, then the<br />

project will try to evaluate the expression as a tag reference and the function will<br />

fail.<br />

To pass the SQL statement so that the project can correctly evaluate the<br />

expression, create a new string tag that contains the text of the expression and<br />

then reference that tag in the SQL statement. For example:<br />

AuxTag = "{Microsoft Text Driver (*.txt; *.csv)}"<br />

DBExecute( "inmates", "SELECT * INTO inmates FROM<br />

OPENROWSET ('MSDASQL','Driver={AuxTag};DEFAULTDIR=C:<br />

\;Extensions=CSV;','SELECT * FROM flat.csv')")<br />

optStrTags<br />

A comma-delimited list of the names of array tags in your project, to which the columns of a<br />

SQL SELECT result set will be mapped. The database values will be copied to these array tags,<br />

with the first row of the result set being copied to array index 0. Make sure the arrays are large<br />

enough to receive all of the rows in the result set.<br />

This parameter is required only when strSQL contains a SQL SELECT statement. For all other<br />

types of statements, this parameter is ignored and can be omitted. However, if you need to<br />

maintain the syntax of the function in order to continue through to optStrErrorTag, then give<br />

this parameter an empty string ("").<br />

optNumMaxRows<br />

The maximum number of rows to be copied from a SQL SELECT result set. In most cases, to<br />

copy all of the rows, specify a number greater than the expected number of rows in the result<br />

set.<br />

This parameter is required only when strSQL contains a SQL SELECT statement. For all other<br />

types of statements, this parameter is ignored and can be omitted. However, if you need to<br />

maintain the syntax of the function in order to continue through to optStrErrorTag, then give<br />

this parameter a value of 0.<br />

optStrErrorTag<br />

The name of a String tag that will receive detailed error messages, if errors occur during<br />

runtime.<br />

Note: The tag name must be enclosed in quotes, as shown in the syntax<br />

diagram, or else the project will try to get the value of the named tag.<br />

This is an optional parameter.<br />

Returned value<br />

This function returns the total number of rows affected by the SQL statement. If an error occurs, then it<br />

returns a negative number.<br />

<strong>InduSoft</strong> Web Studio Page 749

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!