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-10
Execution and Testing of Sample ODBC Application
else
{
printf("c1 :: %d\n", value);
}
}
// ***************** Done with connection 1 ********************
printf("\n\tUsing Connection 2\n\n");
st = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHDBC)hdbc1, &hstmt1);
if (hstmt1 == NULL)
{
printf("Error in allocating statement handle\n");
odbc_Error(SQL_NULL_HENV,SQL_NULL_HDBC,hstmt);
}
st = SQLPrepare(hstmt1,(SQLCHAR *)"insert into GGTest(c1)
values(?)",SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in SQLPrepare\n");
odbc_Error(henv,hdbc1,hstmt1);
}
st =
SQLBindParameter(hstmt1,1,SQL_PARAM_INPUT,SQL_C_SLONG,SQL_INTEGE
R,0,0,&val, 0, &pcbValue);
val = 50;
if(st != SQL_SUCCESS)
{
printf("Error in SQLBindParameter : %d\n", st);
odbc_Error(henv,hdbc1,hstmt1);
}
st = SQLExecute(hstmt1);
if(st != SQL_SUCCESS)
{
printf("Error in SQLExecute : %d\n", st);
odbc_Error(henv,hdbc1,hstmt1);
}
else
printf("Insert Succesfull : %d\n", val);
strcpy(SelectTable,"select * from GGTest" );
st = SQLExecDirect(hstmt1,(SQLCHAR
*)SelectTable,strlen(SelectTable));
if (st != SQL_SUCCESS)
{
printf("Error in select table : GGTest\n");
odbc_Error(henv,hdbc1,hstmt1);
}
Example A-3. Sample ODBC Application Code