printf("Error is occured during getting data from the second column!\n");
SQLError(env,dbc,stmt,sqlstate, &nativeerr, errmsg,
SQL_MAX_MESSAGE_LENGTH - 1, &actualmsglen);
printf("SQLSTATE = %s\nNATIVE ERROR = %d\n", sqlstate, nativeerr);
errmsg[actualmsglen] = '\0';
printf("MSG = %s\n", errmsg);
End(env);
}
code = SQLGetData(stmt,3,SQL_C_SLONG,&rating,(SDWORD)sizeof(rating),&val_rating);
if (code == SQL_ERROR)
{
printf("Error is occured during getting data from the third column!\n");
SQLError(env,dbc,stmt,sqlstate, &nativeerr, errmsg,
SQL_MAX_MESSAGE_LENGTH - 1, &actualmsglen);
printf("SQLSTATE = %s\nNATIVE ERROR = %d\n", sqlstate, nativeerr);
errmsg[actualmsglen] = '\0';
printf("MSG = %s\n", errmsg);
End(env);
}
code = SQLGetData(stmt,4,SQL_C_CHAR,city,(SDWORD)sizeof(city),&val_city);
if (code == SQL_ERROR)
{
printf("Error is occured during getting data from the forth column!\n");
SQLError(env,dbc,stmt,sqlstate, &nativeerr, errmsg,
SQL_MAX_MESSAGE_LENGTH - 1, &actualmsglen);
printf("SQLSTATE = %s\nNATIVE ERROR = %d\n", sqlstate, nativeerr);
errmsg[actualmsglen] = '\0';
printf("MSG = %s\n", errmsg);
End(env);
}
printf("%s %s %d %s\n",n_post,surname,rating,city);
code = SQLFetch(stmt);
if (code == SQL_ERROR)
{
printf("Error is occured during fetching data!\n");
SQLError(env,dbc,stmt,sqlstate, &nativeerr, errmsg,
SQL_MAX_MESSAGE_LENGTH - 1, &actualmsglen);
printf("SQLSTATE = %s\nNATIVE ERROR = %d\n", sqlstate, nativeerr);
errmsg[actualmsglen] = '\0';
printf("MSG = %s\n", errmsg);
End(env);
}
}
//----------------------------------------------------------------------------/* Free operator's identifier */
code = SQLFreeStmt(stmt,SQL_DROP);
if ((code == SQL_SUCCESS) || (code == SQL_SUCCESS_WITH_INFO))
printf("\nOperator identifier is dropped...\n");
else
{
printf("Error is occured while dropped operator identifier!\n");
SQLError(env,dbc,stmt,sqlstate, &nativeerr, errmsg,
SQL_MAX_MESSAGE_LENGTH - 1, &actualmsglen);
printf("SQLSTATE = %s\nNATIVE ERROR = %d\n", sqlstate, nativeerr);
errmsg[actualmsglen] = '\0';
printf("MSG = %s\n", errmsg);
End(env);
}
//----------------------------------------------------------------------------/* Disconnect from data source */
code = SQLDisconnect(dbc);
if (code != SQL_SUCCESS)
{
printf("Error when disconnecting from data source!\n");
End(env);
}
printf("Disconnection with data source is successful...\n");
//----------------------------------------------------------------------------/* Free connection's identifier */
code = SQLFreeConnect(dbc);
if (code != SQL_SUCCESS)
{
printf("Error when free connection's identifier!\n");
End(env);
}
printf("Connection's identifier is free...\n");
//----------------------------------------------------------------------------/* Free enviroment descriptor */
code = SQLFreeEnv(env);
if (code != SQL_SUCCESS)
{
printf("Error when free enviroment descriptor!\n");
End(env);
}
printf("Enviroment descriptor is free...\n");
//----------------------------------------------------------------------------/* Commit transaction */
SQLEndTran(SQL_HANDLE_ENV, env, SQL_COMMIT);
printf("Transaction is commited.\n");
exit(EXIT_SUCCESS);
} /* end of main */
void End(HENV env) /* Exit with rollback transaction */
{
/* Rollback transaction */
SQLEndTran(SQL_HANDLE_ENV, env, SQL_ROLLBACK);
printf("Transaction is canceled.\n\n");
exit(EXIT_FAILURE);
}
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.