CREATE

Creates an object in an application directory.

Syntax #1

Creates an object in an application directory.

CREATE object name [IN dirname]\
 [$fn <filenumber>] [DELETE | KEEP]

CREATE object name [IN dirname]

Parameters

object

One of
constant, directory, display, document, entityset, form, menu, relationship, role, set, variable, window

name

The name to be given to object.

dirname

The name of the application directory in which object is to be created. If dirname is not specified, object is created in the base application directory, called zim.

filenumber

The number of the zim file created to contain the data. For example, if the CREATE command is invoked with $fn 400, Zim attempts to associate file zim0400 with the created object. It is sometimes useful to associate a particular filenumber with a particular object: if the object was erased with the KEEP option, the create command recreates it with the KEEP option.

DELETE

When DELETE is specified, the existing database file, if present, is deleted before a new file is created. If DELETE is not specified and a file exists, an error message indicates that Zim is unable to create the object.

KEEP

When KEEP is specified, the existing database file, if present, is kept instead of creating a new one. If the file does not exist, a new (empty) database file is created.

Syntax #2

Creates an index.

CREATE INDEX ownername.fieldname [UNIQUE]

Syntax #3

Creates a field.

CREATE FIELD ownername fieldname

Parameters

ownername

The name of the EntitySet, relationship with fields, or application document to which fieldname belongs.

fieldname

The name of the field in ownername to index or to create.

UNIQUE

If UNIQUE is specified, any duplicate key values are rejected and do not appear in the index.

Comments

The application directory named in a CREATE command must have been accessed in update mode (see ACCESS) and all information needed to define the object must exist in the Object Dictionary. For CREATE to proceed, the explicit dirname in the CREATE command (or the implicit directory zim) must match the owner-directory specified for object in the Object Dictionary; or, there must be no owner-directory specified for object in the Object Dictionary. In the latter case, object can be created in any or in every application directory available in the database (except foreign directories).

A field or form field cannot have the same name as an existing variable, EntitySet, relationship, role, directory, application document, window, constant, result set, form, menu, or display in the same application directory. Several fields or several form fields can have identical names, provided that each identically named field belongs to a different ownername.

There is an internal limit of 65000 CREATEs per Zim directory in Zim.  If this limit is exceeded, a 3029 error is generated. For more information, see Zim Error Codes.  To resolve this error, export all objects and import these objects into a newly initialized Zim database.  In a newly initialized database, the CREATE counter is reset to 0.

Example

create entityset Employees in Personnel

Creates an EntitySet called Employees in the application directory Personnel.

create index Employees.FirstName

Creates an index for an un-indexed field FirstName in the Employees EntitySet.

 

Related Topics