Databases Reference
In-Depth Information
4.3.3 Inventory program code template
We start off with a simple code skeleton of the application (see Example 4-5 on
page 155). This C program prompts the user for an inventory operation and calls
the appropriate functions to insert ( add_product() ), update ( update_product() ),
or perform queries ( query_update() ) against the INVENTORY table in the SAMPLE
database. Applications can be written to contain both static and dynamic
embedded SQL statements. For demonstration purposes, this application
contains both types.
Example 4-4 Code template of inventory.sqc
/******************************************************
** Source File Name: inventory.sqc
**
** This simple C program will manage the inventory of
** products for a company.
**
*******************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void add_product(void);
void update_product(void);
void query_product(void);
main()
{
int option;
while(1){
printf("-------------------------------------------------\n");
printf(" SIMPLE INVENTORY MANAGEMENT SYSTEM \n\n");
printf(" 1. Add New Product \n");
printf(" 2. Update Product Info (Quantity or Location) \n");
printf(" 3. Query Product \n");
printf(" 4. Exit \n\n");
printf(" Enter option: ");
scanf("%d", &option);
switch(option) {
case 1:add_product();
break;
case 2:update_product();
Search WWH ::




Custom Search