Previous Topic

Next Topic

Define

The Define() step is where specific data definitions are established by your application and/or process. This involves defining columns/fields and creating the tables/files with optional indices.

Below is the code for Define():

/*
 * Define()
 *
 * Create the table for containing a list of existing customers
 */
void Define(void)
{
   os_printf(DH_STRING_LITERAL("DEFINE\n"));

   /* create table */
   os_printf(DH_STRING_LITERAL("\tCreate table…\n"));
   EXEC SQL CREATE TABLE custmast (
         cm_custnumb CHAR(4),
         cm_custzipc CHAR(9),
         cm_custstat CHAR(2),
         cm_custrtng CHAR(1),
         cm_custname VARCHAR(47),
         cm_custaddr VARCHAR(47),
         cm_custcity VARCHAR(47)
      ) ;
   if (sqlca.sqlcode)
      Handle_Error(sqlca.sqlcode, sqlca.sqlerrm);

   EXEC SQL COMMIT WORK;
}