Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## = Assignment operator

> Assigns the value of an expression to a database field or variable.

> #### Data movement

> #### Syntax

>     field = expression [ NO-ERROR ]

> ``field``

> The name of a database field or variable to which you want to assign the value of the expression. If the field is an array, and you do not name a particular element, Progress stores `expression` in each element of the array. If you name a particular element, Progress stores `expression` in that element.

> The left side of an assignment can also be an attribute or Progress keyword (such as ENTRY, FRAME-VALUE, SUBSTRING, or OVERLAY).

> ``expression``

> An expression with a data type that is consistent with the data type of the `field`. If `field` is integer and `expression` is decimal, then Progress rounds the value of the expression before assigning it. If `field` is decimal and `expression` is decimal, then Progress rounds the value of the expression to the number of decimal places defined for the field in the Dictionary or defined or implied for a variable.

> `NO-ERROR`

> Suppresses any errors that occur as a result of the operation. After the assignment completes, you can check the ERROR-STATUS system handle for information about any errors that might have occurred.

> If you do not specify this option and an error occurs, the assignment is canceled and any changes to field values within the assignment are undone. If the assignment occurs within a transaction, any changes to variables, work table fields, and temporary table fields are also undone, unless you define the variable or field with the NO-UNDO option.

> Example

> This procedure resets all the monthly quota values to 0 in all salesrep records. If you want to set values for individual array elements, you can do so by making an explicit assignment using the assignment statement and a specific array reference, such as month-quota[1] or month-quota[i].

> r-asgmnt.p
>     DEFINE VARIABLE ctr   AS INTEGER.

>     FOR EACH salesrep:
>       DO ctr = 1 TO 12:
>         salesrep.month-quota = 2500.
>       END.
>     END.

> #### Notes

> - If you assign a value to a database field, any ASSIGN trigger associated with that field executes at the end of the assignment statement (after any index changes are made). If the trigger returns ERROR, the assignment fails and the database changes are undone.

> - You can embed an assignment in a SET or UPDATE statement.

> - For multiple assignments, use the ASSIGN statement. This is more efficient than multiple assignment statements.

> - You can assign DATE, DATETIME, and DATETIME-TZ data. When the data type expression on the left side of the assignment statement contains more information than the data type expression on the right side provides (for example, `datetime-tz = date` where a DATETIME-TZ value contains more information than a DATE value), the time value defaults to midnight and the time zone value defaults to the session's time zone. When the data type expression on the left side of the assignment statement contains less information than the data type expression on the right side provides (for example, `date = datetime-tz` where a DATE value contains less information than a DATETIME-TZ value), Progress converts the DATETIME-TZ value to the local date and time of the session, then drops the time and time zone.

> - You can assign large object data from one BLOB or MEMPTR to another, and from one CLOB, LONGCHAR, or CHARACTER to another. You cannot assign large object data between BLOBs and CLOBs or MEMPTRs and LONGCHARs. You can accomplish this, indirectly, by using the COPY-LOB statement. For more information, see the COPY-LOB statement reference entry.

> Note: When assigning BLOB or CLOB fields, the field must appear by itself on either the right-hand or the left-hand side of the assignment.

> Table 8 lists the default character conversions Progress performs when assigning CLOB, LONGCHAR, and CHARACTER data between a source and target object. References to CLOBCP and CLOBDB represent CLOB data in either the CLOB’s defined code page or the database's defined code page, respectively. References to the "fixed code page" represent the code page of a target LONGCHAR variable set using the FIX-CODEPAGE function.

> Table 8: Default Assignment operator character conversions
> When the target object (on the left) is a ... | And the source object (on the right) is a ... | Progress converts the data in the source object to ...
> --- | --- | ---
> LONGCHAR | CLOBDB | `-cpinternal` or the fixed code page.
> LONGCHAR | CLOBCP | The CLOB’s defined code page or the fixed code page.
> LONGCHAR | CHARACTER | `-cpinternal` or the fixed code page.
> CLOBDB | CHARACTER | The database's defined code page.
> CLOBDB | LONGCHAR | The database's defined code page.
> CLOBCP | CHARACTER | The CLOB’s defined code page.
> CLOBCP | LONGCHAR | The CLOB’s defined code page.
> CHARACTER | CLOBDB | `-cpinternal` code page.
> CHARACTER | CLOBCP | `-cpinternal` code page.
> CHARACTER | LONGCHAR | `-cpinternal` code page.

> - When you assign the Unknown value (`?`) to a BLOB or CLOB field, Progress deletes any associated object data.

> #### See also

> ASSIGN statement, Data types, COPY-LOB statement, FIX-CODEPAGE function

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