HP Integrity NonStop H-Series User Manual
Page 59

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;
}
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_INTEGER
,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
Testing the sample
59