Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## CREATE statement

> Creates a record in a file, sets all the fields in the record to their default initial values, and moves a copy of the record to the record buffer.

> #### Data movement

> #### Syntax

>     CREATE record
>       [ USING { ROWID ( nrow ) | RECID ( nrec ) } ] [ NO-ERROR ]

> ``record``

> The name of the record or record buffer you are creating.

> To create a record in a file defined for multiple databases, you might have to qualify the record’s filename with the database name. See the Record phrase reference entry for more information.

> `USING { ROWID ( `nrow` ) | RECID ( `nrec` ) }`

> Supported only for backward compatibility.

> `NO-ERROR`

> Specifies that any errors that occur in the attempt to create the record are suppressed. After the CREATE statement completes, you can check the ERROR-STATUS system handle for information on any errors that might have occurred.

> Example

> The following example creates a record in the order file for each pass through the loop and then updates the record. It also creates an order-line record.

> r-create.p
>     REPEAT:
>         CREATE order.
>         UPDATE order.order-num
>                order.cust-num VALIDATE(CAN-FIND(customer OF order),
>                                        "Customer does not exist")
>                cust-num order-date.
>         REPEAT:
>            CREATE order-line.
>            order-line.order-num = order.order-num.
>            UPDATE line-num
>            order-line.item-num VALIDATE(CAN-FIND(item OF order-line),
>                                         "Item does not exist")
>            qty
>            price.
>         END.
>     END.

> This procedure adds orders and order-lines to the database. Because the user supplies an order number when updating the order record, that order number is assigned (=) to the order-num field of the order-line record when the order-line record is created.

> #### Notes

> - When you run procedures that create large numbers of records (for example, during initial data loading), the process runs much faster if you use the No Crash Protection (-i) parameter. See OpenEdge Deployment: Startup Command and Parameter Reference for more information on startup parameters. Back up your database before you use this parameter.

> - After you create a new record with CREATE, Progress waits to write the record to the database until after the next statement generates an index entry for the record.

> - The CREATE statement causes any related database CREATE triggers to execute. All CREATE triggers execute after the record is actually created. If a CREATE trigger fails (or executes a RETURN statement with the ERROR option), the record creation is undone. See OpenEdge Development: Progress 4GL Handbook for more information on database triggers.

> #### See also

> INSERT statement, NEW function

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095