Add test case for using SQLBindParameter with SQLExecDirect.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 20 Aug 2013 19:41:53 +0000 (22:41 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 20 Aug 2013 20:09:17 +0000 (23:09 +0300)
test/expected/params.out
test/src/params-test.c

index 3a9267cd6901c650f2514e1557f8e486697238bf..c9154d83658acd34f1475e01a9d95d7393405885 100644 (file)
@@ -3,4 +3,7 @@ connected
 # of result cols: 2
 Result set:
 1  0102030405060708
+Result set:
+foo
+bar
 disconnecting
index 837c98e74ae87bad1e107a0a54fe8e9dc3f25b14..720cce2e73214bc07458dc4b37b7b5fb803a1f79 100644 (file)
@@ -55,6 +55,28 @@ int main(int argc, char **argv)
    rc = SQLFreeStmt(hstmt, SQL_CLOSE);
    CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
 
+   /*** Test SQLBindParameter with SQLExecDirect ***/
+
+   /* bind param  */
+   strcpy(param1, "bar");
+   cbParam1 = SQL_NTS;
+   rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
+                         SQL_C_CHAR,   /* value type */
+                         SQL_CHAR,     /* param type */
+                         20,           /* column size */
+                         0,            /* dec digits */
+                         param1,       /* param value ptr */
+                         0,            /* buffer len */
+                         &cbParam1     /* StrLen_or_IndPtr */);
+   CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
+
+   rc = SQLExecDirect(hstmt, (SQLCHAR *) "SELECT 'foo' UNION ALL SELECT ?", SQL_NTS);
+   CHECK_STMT_RESULT(rc, "SQLExecDirect failed", hstmt);
+   print_result(hstmt);
+
+   rc = SQLFreeStmt(hstmt, SQL_CLOSE);
+   CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
+
    /* Clean up */
    test_disconnect();