Product Documentation

FairCom Low-Level API for C

Previous Topic

Next Topic

Create

Below is the code where specific data definitions are established by your application and/or process. With this code, you will "Create" columns/fields and creating the tables/files with optional indexes:

/********************************************************

* *

* db_create: creates the data files and indexes. *

* If any of the files already exist there *

* will be an error. The files are closed *

* so all intended file modes take effect. *

* *

********************************************************/

#ifdef PROTOTYPE

VOID db_create(void)

#else

VOID db_create()

#endif

{

/* Create the data file */

if (CreateDataFile(INVENTDAT,"invent.dat",sizeof(invent),4096,ctVIRTUAL|ctSHARED|ctFIXED))

terminate("Could not create invent.dat",INVENTDAT);

/* the second parameter is no longer used */

if (CloseCtFile(INVENTDAT,0))

terminate("Could not close invent.dat after creation",INVENTDAT);

/* Create the index file */

if (CreateIndexFile(INVENTIDX,"invent.idx",25,0,0,0,4096,ctVIRTUAL|ctSHARED))

terminate("Could not create invent.idx",INVENTIDX);

if (CloseCtFile(INVENTIDX,0))

terminate("Could not close invent.idx after creation",INVENTIDX);

printf("\nSuccessfully created data files and indices");

return;

}

TOCIndex