Download Database - National Instruments
Transcript
Chapter 5
SQL Toolkit Library Reference — DBSetStatementAttribute
Bookmark and Filter Example
VARIANT vFilterArray;
int filterIndex = 0;
VARIANT bookmarks[2];
hstmt = DBNewSQLStatement (hdbc, "SELECT UUT_NUM, MEAS1, \
MEAS2 FROM TESTRES");
resCode = DBOpenSQLStatement(hstmt);
/* Criteria string example.
*/
/* Note: It almost always much more efficient to use a
*/
/* where clause in the SQL statement, instead of using a */
/* criteria string in a filter.
*/
CA_VariantSetCString (&filter, "(MEAS1 > 1.0)");
resCode = DBSetStatementAttribute(hstmt, ATTR_DB_STMT_FILTER, filter);
while ((resCode = DBFetchNext (hstmt)) == DB_SUCCESS) {
/* Only records where MEAS1 greater than 1.0. */
...
}
/* Filter constant example. */
CA_VariantSetLong (&filter, DB_FILTER_NONE);
resCode = DBSetStatementAttribute(hstmt, ATTR_DB_STMT_FILTER,
filter);
i = 0;
while ((resCode = DBFetchNext (hstmt)) == DB_SUCCESS) {
/* Will get all records. */
...
/* Get some bookmarks to use in next example. */
if ((i == 0) || (i == 2)) {
resCode = DBGetStatementAttribute(hstmt, ATTR_DB_STMT_BOOKMARK,
&(bookmarks[filterIndex++]));
i++;
...
}
/* Bookmark array example. */
CA_VariantSet1DArray (&vFilterArray, CAVT_VARIANT, 2, bookmarks);
resCode = DBSetStatementAttribute(hstmt,
ATTR_DB_STMT_FILTER, vFilterArray);
while ((resCode = DBFetchNext (hstmt)) == DB_SUCCESS) {
/* Will only get records at the bookmarks we
*/
/* obtained in the previous example.
*/
...
}
resCode = DBCloseSQLStatement(hstmt);
© National Instruments Corporation
5-261
LabWindows/CVI SQL Toolkit Reference Manual
Related documents
LabWindows/CVI SQL Toolkit Reference Manual
Informix CLI Programmer`s Manual, Version 2.8
Informix CLI Programmer`s Manual, Version 2.5
Getting Started Guide - ALTIBASE Customer Support
AspectMatlab - Sable Research Group
A+CAL User`s Manual - Microsoft Research
A PlusCal User`s Manual
Getting Started - Mimer SQL - Mimer Information Technology AB