Open System Services ODBC/MX Client Driver (SQL/MX 2.x)

Sample ODBC Application
HP NonStop Open System Services ODBC/MX Client Driver544990-002
A-9
Execution and Testing of Sample ODBC Application
memset(InsertTable, '\0', sizeof(InsertTable));
sprintf(InsertTable, "%s %d %s", "insert into GGTest(c1) values
(", value2, ");");
st = SQLExecDirect(hstmt,(SQLCHAR*)InsertTable,SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in Insert Table 2: GGTest\n");
odbc_Error(henv,hdbc,hstmt);
}
else
printf("Insert Succesfull: %d\n", value2);
st = SQLRowCount(hstmt,&RowCount);
if (st != SQL_SUCCESS)
{
printf("Error in SQLRowCount()\n");
odbc_Error(henv,hdbc,hstmt);
}
else
printf("Row(s) affected %d\n", RowCount);
st = SQLExecDirect(hstmt,(SQLCHAR
*)SelectTable,strlen(SelectTable));
if (st != SQL_SUCCESS)
{
printf("Error in Select Table: GGTest\n");
odbc_Error(henv,hdbc,hstmt);
}
st = SQLBindCol(hstmt, 1, SQL_C_SLONG, &value, 0, &ValInd);
if (st != SQL_SUCCESS)
{
printf("Error in SQLBindCol\n");
odbc_Error(henv,hdbc,hstmt);
}
while(TRUE)
{
if ((st = SQLFetch(hstmt)) == SQL_NO_DATA_FOUND)
break;
if ( (st != SQL_SUCCESS) && (st != SQL_SUCCESS_WITH_INFO) )
{
printf("Error in SQLFetch!!! Returned Status: %d\n", st);
break;
}
if (ValInd == SQL_NULL_DATA)
{
printf("No Data fetched!\n");
break;
}
Example A-3. Sample ODBC Application Code