WRITE

Contents


Write is used to create a record in a table.

 

Syntax

   Write [ class ]

 

Parameters

Element

Description

Restrictions

class

Abbreviation for a table, by default, the default table.

The table must have been opened by a File command.

 

Example

   # Input and write a record to the [TEST] file
    File TEST [TEST]    :# declaration of the TEST file
    Mask TEST [TEST]    :# declaration of the TEST mask
    Inpbox Mask [TEST] ... As [INP1]  :# declaration of the box
    Boxact [INP1]       :# Display input box
    Boxinp [INP1]...    :# Input to the box
    ...   
    [F] = [M]            :# transfer variables from the mask to those of the file
    Trbegin [TEST]      :# start of transaction
   
Write [TEST]       :# write to a file
    If [S]fstat         :# if there is any problem
      Rollback           :# the transaction is cancelled
    Else        
      Commit             :# otherwise it is validated
      Read [TEST]CODCLE = [F:TEST]CODCLE :# you go to it
    Endif

   # Write a record to the default file
   Write

 

Description and comments

Write is used to write a new record in a table. Indices are updated automatically.

Write updates the variable fstat to show the progress of the write operation.

fstat

Code

Ecr.

Explanation

0

Yes

The write took place correctly.

1

ERLOCK

No

Table locked.

3

ERDUPCL

No

Attempt to create a duplicate key.

A Write instruction does not modify the current record. This means that in general a read must be performed in order to go to the new record.

 

Comment

A new record must be written within a transaction.

Until the transaction is complete, the new record will not be visible to other users.

A link abbreviation may not be used to write a record.

Using Lock [abrv] to lock a file prevents other users from creating new records with Write. In this case, the fstat variable is set to 1.

 

Associated errors

Error

Description

ERCLAS ( 7)

The file class does not exist (file not open).

ERACCE (27)

Attempt to write a file with a 'link abbreviation'.

ERMDISK (44)

No more disk space.

ERULIM (65)

Maximum size (ulimit) exceeded.

ERORA (75)

Oracle error.

 

Associated key words

FILE - REWRITE - READ - TRBEGIN - COMMIT - ROLLBACK - FSTAT


CONTENTS


Copyright © Sage 1999 - 2007