CREATE statement

Syntax

CREATE file.variable {THEN statements [ELSE statements] | ELSE 
statements}

Description

Use the CREATE statement after an OPENSEQ statement to create a record in a type 1 or type 19 file or to create a UNIX or DOS file. CREATE creates the record or file if the OPENSEQ statement fails. An OPENSEQ statement for the specified file.variable must be executed before the CREATE statement to associate the path name or record ID of the file to be created with the file.variable. If file.variable is the null value, the CREATE statement fails and the program terminates with a run-time error message.

Use the CREATE statement when OPENSEQ cannot find a record or file to open and the next operation is to be a NOBUF statement, READSEQ statement, or READBLK statement. You need not use the CREATE statement if the first file operation is a WRITESEQ statement, since WRITESEQ creates the record or file if it does not exist.

If the record or file is created, the THEN statements are executed, and the ELSE statements are ignored. If no THEN statements are specified, program execution continues with the next statement.

If the record or file is not created, the ELSE statements are executed; any THEN statements are ignored.

File Buffering

Normally InfoSphere® DataStage® uses buffering for sequential input and output operations. Use the NOBUF statement after an OPENSEQ statement to turn off buffering and cause all writes to the file to be performed immediately. For more information about file buffering, see the NOBUF statement.

Example

In the following example, RECORD4 does not yet exist. When OPENSEQ fails to open RECORD4 to the file variable FILE, the CREATE statement creates RECORD4 in the type 1 file FILE.E and opens it to the file variable FILE.

OPENSEQ 'FILE.E', 'RECORD4' TO FILE
   ELSE CREATE FILE ELSE ABORT
WEOFSEQ FILE
WRITESEQ 'HELLO, UNIVERSE' TO FILE ELSE STOP