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: This feature emulates SQL (Structured Query Language) database operations. You should be<br />

familiar with how SQL commands are formed and executed before you use this feature.<br />

Syntax<br />

DBCursorOpenSQL( strDBConn, strSQL, optStrTags, "optStrErrorTag" )<br />

strDBConn<br />

strSQL<br />

The name of the database connection. Connections are configured in the Database/ERP folder.<br />

A string that gives a complete, syntactically correct SQL SELECT statement.<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 tags in text fields that are<br />

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

SQL statement that includes such an expression to DBCursorOpenSQL, 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 the tag in the SQL statement. For example:<br />

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

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

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

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

optStrTags<br />

A string that lists the project tags to which the columns will be mapped. This list of tag names<br />

should be comma-delimited and in the same order as the columns specified by the WHERE<br />

clause of strSQL. As the cursor is moved through the result set, the values in the current row<br />

are copied to these tags.<br />

optStrErrorTag<br />

This is an optional parameter. If no tags are specified, then no values will be copied.<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 />

Returns a numeric value that represents the cursor handle. In case of error, returns a negative number.<br />

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

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

Saved successfully!

Ooh no, something went wrong!