Function DbCreate() Foundation

Generates a database file from a file structure array.

Syntax
DbCreate( <cDbfFile>, <aStructure>, [<cDBE|<oSession>] ) --> NIL
Parameters
<cDbfFile>
<cDbfFile> is a character string containing the name of the new database file. It can include drive and path specifications. DBF is used as the default extension.
<aStructure>
<aStructure> is a two dimensional array containing the structure of <cDbfFile>. Each subarray contains the specification for a field and must include the following:
Structure for a subarray to the field specification
Element No. Description Constant in Dbstruct.ch
1 Field name DBS_NAME
2 Field type DBS_TYPE
3 Field length DBS_LEN
4 Decimal places DBS_DEC
<cDBE>
<cDBE> is a character string containing the name of the database engine (DBE) used to manage the database file and its index files.
<oSession>
<oSession> optionally specifies the Session context for the operation. oSession is an object of DacSession() or any derived class. If oSession is not specified the current session of the current thread is used.
Return

The return value of DbCreate() is always NIL.

Description

The database function DbCreate() creates an empty database file from the two dimensional array <aStructure> containing the field specifications for each field in the file. Each subarray contains four elements which specify the field name, field type, field length and number of decimal places. The number of decimals must always be specified and should be set to zero for all field types except numeric. The length of character fields depends on the database engine (DBE) being used. For compatibility reasons the DBFDBE supports character fields only up to 64KB in length.

A new database file can also be created using the commands CREATE and CREATE FROM which use a DBF file containing the field definitions.

Examples
DbCreate()
// In the example, a two dimensional array containing the 
// structure definition for a database file to contain personnel 
// data is created. The file PERSONAL.DBF is created using 
// DbCreate(). 

PROCEDURE Main 
   LOCAL aStructure := { ; 
           { "EMPLOYEENO"   , "C",  6, 0 }, ; 
           { "LASTNAME"     , "C", 20, 0 }, ; 
           { "FIRSTNAME"    , "C", 20, 0 }, ; 
           { "BIRTHDATE"    , "D",  8, 0 }, ; 
           { "GENDER"       , "L",  1, 0 }, ; 
           { "DEPARTMENT"   , "C", 20, 0 }, ; 
           { "INCOME"       , "N",  9, 2 }, ; 
           { "STREET"       , "C", 30, 0 }, ; 
           { "CITY"         , "C", 30, 0 }, ; 
           { "STATE"        , "C",  2, 0 }, ; 
           { "ZIP"          , "C",  5, 0 }, ; 
           { "TELEPHONE"    , "C", 15, 0 }, ; 
           { "MEMO"         , "M", 10, 0 }  ; 
         } 

   DbCreate( "EMPLOYEE", aStructure, "DBFNTX" ) 

   USE Employee NEW 
   Browse() 
   USE 

RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.