Databases Reference
In-Depth Information
sprintf(updateStmt,"update inventory set %s='%s' where PID='%s'",
updateField, updateValue, PID);
else
sprintf(updateStmt,"update inventory set %s=%s where PID='%s'",
updateField, updateValue, PID);
EXEC SQL EXECUTE IMMEDIATE :updateStmt;
EXEC SQL COMMIT;
printf("\n Product successfully updated.");
return;
errorFound: {
printf("\n Error: Problem occurred. Sqlcode: %d Sqlstate:
%s\n",sqlca.sqlcode, sqlca.sqlstate);
return;
}
PIDNotFound: {
printf("\n Error: Product ID was not found. \n");
return;
}
}
/******************************************************
** This function will query for information on a
** product in the INVENTORY table using static SQL
*******************************************************/
void query_product(void)
{
printf("-------------------------------------------------\n");
printf(" Query A Product \n\n");
printf(" Enter Product ID : ");
scanf("%s", &PID);
EXEC SQL WHENEVER SQLERROR GOTO errorFound;
EXEC SQL WHENEVER NOT FOUND GOTO PIDNotFound;
EXEC SQL SELECT quantity, location INTO :quantity, :location from
inventory where PID=:PID;
printf(" Found Quantity : %d\n",quantity);
printf(" Location : %s\n",location);
EXEC SQL COMMIT;
return;
Search WWH ::




Custom Search