Open System Services ODBC/MX Client Driver Manual for SQL/MX Release 3.2.1 (H06.26+, J06.15+)

}
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);
}
st = SQLBindCol(hstmt1, 1, SQL_C_SLONG, &value, 0, &ValInd);
if(st != SQL_SUCCESS)
{
printf("Error in SQLBindCol\n");
odbc_Error(henv,hdbc1,hstmt1);
}
while(TRUE)
{
if ((st = SQLFetch(hstmt1)) == 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;
}
Execution and Testing of Sample ODBC Application 59