Create DS

PURPOSE:  The CREATE DS command creates a Data Set  (DS) and associates it with a Schema Definition (SD).  The command can be used to create a new DS or to associate it with existing file as a DS and associate it with the current Data Base Library (DBL) entry.  If the KEYED ON clause is used, this command also defines a RAM Data Index (DI) for the DS.  This command may be used to create a table or attach to a table within a data server such as Oracle, and RMS.

SYNTAX

CREATE DS name SD /IS/ sd_name

[CREATE/IF MISSING/; ENTRY/ONLY/; ATTACH]

[KEYED ON field1 [… AND fieldn]]

name

assigns the name to the DS established with this command.  Unless the ATTACH clause is specified a file or table will be created for the data set.

sd_name

references an existing SD that describes the DS being established with this command.  See DEFINE SD in this chapter for information on defining SD’s.  The associated SD must exist before the CREATE DS command is issued.

CREATE/IF MISSING/

creates a DBL entry for the DS, then checks for the existence of the associated DS file or table and creates it if it does not exist.  If a DS file or table already exists, ACCENT R attaches it to the DBL entry, and it is recognized as the data for the DS.  The SD referenced in the command must already exist in the current DBL, and its description must match the format of the records in the attached table if the table exists.  See the notes that follow on attaching a DS.

ENTRY /ONLY/

creates a DBL entry for the DS but does not check for the existence of an associated DS file or table.

ATTACH

specifies that a file or table exists outside the current DBL is to be recognized as the data for this DS.  If no file or table of the specified DS name exists, ACCENT R aborts the command and displays an error message.

[.KEYED ON field] [… AND fieldn]]

names the fields that will serve as domains in a RAM DI established with this command.  A DI created by this command has the same name as the DS with the extension .DI.  Each domain will have only one field, and the domain name will be the same as the field name.  The options DUPLICATES ALLOWED and KEY CHANGES ALLOWED are assumed.  See DEFINE DI in this chapter for more discussion on the creation and use of DI’s.

EXAMPLES

The following example assumes the system file SALES_DBM2.DS exists.

*CREATE DS SALES_DBM2 SD IS SALES_DBM2 ATTACH

This example will create the system file STORES_DBM2.DS for the Data Set; the system file for the DI called (STORES_DBM2.DI) and a DI entry in the DBL.

*CREATE DS STORES_DBM2 SD IS STORES_DBM2 KEYED ON ZIP AND STATE

NOTES:  If a DBL entry for the specified DS already exists, ACCENT R aborts CREATE DS command and display an error message.

If an existing System File (SF) is referenced in the CREATE DS command without the CREATE IF MISSING, ENTRY ONLY or ATTACH option, ACCENT R aborts the command and displays an error message.

Attaching a DS simply creates an object in the DBL for the attached DS; ACCENT R does no error checking when a DS is attached.  The system field @RECORDS for an attached DS is zero unless updated by the COUNT command.  You can use the CHECK command instructing the ACCENT R to check the data against the SD definition.