Selects a set of rows and columns in a database table, initializes the cursor at the first row of the result set, copies that row's values to mapped tags, and then returns a cursor handle that can be referenced by other DB/ERP functions. (This function is equivalent to a SQL SELECT statement.)
Function | Group | Execution | Windows | Embedded | Thin Client |
---|---|---|---|---|---|
DBCursorOpenSQL | Database/ERP | Synchronous | Supported | Supported | Supported |
DBCursorOpenSQL( strDBConn, strSQL, optStrTags, "optStrErrorTag" )
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 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 DBCursorOpenSQL, then the project will try to evaluate the expression as a tag reference and the function will fail.
$AuxTag = "{Microsoft Text Driver (*.txt; *.csv)}" $DBCursorOpenSQL( "inmates", "SELECT * INTO inmates FROM OPENROWSET ('MSDASQL','Driver={AuxTag};DEFAULTDIR=C:\;Extensions=CSV;','SELECT * FROM flat.csv')")
This is an optional parameter. If no tags are specified, then no values will be copied.
This is an optional parameter.
Returns a numeric value that represents the cursor handle. In case of error, returns a negative number.
See also DBCursorClose.
Tag Name | Expression |
---|---|
nCursor | DBCursorOpenSQL( "DB1", "SELECT Column1, Column2 FROM Table1 WHERE Column1 > 3 ORDER BY Column1, Column2 DESC", "Tag1, Tag2") |