Product Documentation

FairCom ODBC

Previous Topic

Next Topic

Define

Define() establishes specific data definitions. This involves defining columns/fields and creating the tables/files with optional indexes.

Below is the code for Define():

/*

* Define()

*

* Create the table for containing a list of existing customers

*/

void Define(void)

{

RETCODE rc;

printf("DEFINE\n");

/* create table */

printf("\tCreate table...\n");

if ((rc = SQLExecDirect(hStmt,

"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))",

SQL_NTS)) != SQL_SUCCESS)

Handle_Error(SQL_HANDLE_STMT, hStmt, "SQLExecDirect(CREATE TABLE)");

if ((rc = SQLExecDirect(hStmt,

"CREATE UNIQUE INDEX cm_custnumb_idx ON custmast (cm_custnumb)",

SQL_NTS)) != SQL_SUCCESS)

Handle_Error(SQL_HANDLE_STMT, hStmt, "SQLExecDirect(CREATE INDEX)");

if ((rc = SQLExecDirect(hStmt, "COMMIT WORK", SQL_NTS)) != SQL_SUCCESS)

Handle_Error(SQL_HANDLE_STMT, hStmt, "SQLExecDirect(COMMIT WORK)");

}

TOCIndex