WRITE (IFILE)


ANSI

 

The WRITE instruction transfers information from program variables into a disk file.

 

(1)

[label]

WRITE

{ifile}[,{key}];[{list}][;]

(2)

[label]

WRITE

{ifile}[,{key}];[columnname={variable}][,...]]

 

Where:

label

Optional. A Program Execution Label.

file

Required. A previously defined and opened IFILE variable in which data is written.

key

Optional. A previously defined Character String Variable or Numeric Variable containing the index key associated with this record.

list

Optional. Any combination of previously defined Character String Variables, Numeric Variables, string or numeric ARRAYs, individual array elements, VARLISTs of string or numeric variables, or valid Disk I/O List Controls.

;

Optional. A semicolon indicating Partial I/O.

columnname

Required. The column name as specified in the VIEW that was assigned to the file variable by the OPEN or PREPARE instruction. The column named is not case sensitive.

variable

Required. The variable that has been previously declared and loaded with data to be written.

Flags Affected: LESS, OVER, ZERO

Note the following:

  1. The Logical String of {key} is the index key associated with this record.

  2. If {key} is not specified, the key is constructed using the data in {list}.

  3. Duplicate ISAM keys are allowed unless the `N' option was used during the most recent indexing of the file. The `N' option in the INDEX utility signifies that duplicate ISAM keys are not allowed and that a trappable I/O error occurs if an attempt is made to write or insert a duplicate key to the file.

  4. {list} may be any combination of character string and/or numeric variables (including arrayed items), character string and/or numeric literals, Ctrl values and/or supported list controls separated by commas. If an ARRAY variable is given without a specific array element designated, all elements of the array are processed.

  5. Ctrl values and literals are written to the disk exactly as specified in {list}.

  6. The supported list controls are as follows:

  7.  

    Control

    Function

    *+

    Enable space compression

    *-

    Disable space compression

    *CDFOFF

    Disable *CDFON

    *CDFON

    Enable comma-delimited Field support

    *EDIOFF

    Disable *EDION

    *EDION

    Enable Electronic Data Information support

    *LC

    Data is written in the case in which it was stored

    *LL

    Forces output of only the Logical String

    *MP

    Minus overpunch negative numeric variables

    *PL

    Disable *LL (default)

    *UC

    lower case characters are converted to upper case before being written

    *ZF

    Zero-fill numeric variables

    *ZS

    Blank-fill zero numeric variables

 

  1. Tabbing is not allowed with the WRITE instruction. If tabbing is desired, the WRITAB instruction should be used.

  2. If a semi-colon (;) terminates the list, the rules applying to partial writes apply (see Partial I/O). Partial IO is not allowed for SQLIO.

  3. Any records written to a fixed length record file that are shorter than the declared record size are padded with blanks and the LESS flag is set.

  4. Any records written to a fixed length record file that are longer than the declared record size or to a variable length record file that are longer than the maximum record size are truncated and the OVER flag is set.

  5. When using the single unlocking mode, a WRITE to a record that is not locked unlocks the currently locked record before the WRITE begins.

  6. When using the single unlocking mode, a WRITE to a locked record unlocks the record when the operation completes.

  7. When a view schema is assigned to an IFILE variable (9.4), the WRITE instruction can optionally use the column name syntax (format 2 above). When the column name syntax is being used, all variables used in the instruction variable list must have column names specified. When the column name syntax is not being used, no variables in the instruction variable list can have column names.

  8.  

    If the column name syntax specified with the 'columnname' parameter is being used, the 'columnname' parameter can be one of the following:

     

    Column name as specified by the VIEW column definitions.

     

    @{svar} where {svar} is a variable that contains the column name as specified by the VIEW column definitions.

    Example:

    IFILE IFILE

    myKey DIM 10

    myProdid DIM 10

    myParam DIM 50

    ...

    . Both of these WRITE syntax formats give the same results when

    . using a VIEW definition column name of 'PRODID' and the IFILE

    . is opened with VIEW definition being used.

    .

               WRITE IFILE, myKey; PRODID=myProdid

    .

               MOVE "PRODID", myParam

               WRITE IFILE, myKey; @myParam=myProdid

    .

  9. If the column name syntax format is being used, partial IO using the semicolon character (;) is not allowed and a runtime error will result.

  10. If the column name syntax format is being used and all of the view column names are not included in the WRITE variable list, any unspecified fields are either blank filled or filled with a default value specified in the view schema. For a file opened or created with fixed length records, the WRITE instruction writes the full record with appropriate default data for unspecified fields. For a file opened or created with variable length records, the WRITE instruction writes all of the fields up to and including the last column that has been specified with unspecified fields being appropriately filled with default data.

 

 

See Also: Example Code, READ (IFILE), DELETE (IFILE), UPDATE (IFILE), Disk I/O Instructions

 



PL/B Language Reference WRITE (FILELIST)