PUT

Syntax

PUT {src_any_lit|_var|_col}... INTO dst_array_name(element)[field[(occurs)]]...

Description

Moves data into an array.

Columns retrieved from the database and SQR variables or literals can be moved into an array. The array must have been created previously by the CREATE-ARRAY command.

Parameters

Parameter Description

src_any_var

The source variable or literal to be moved into the array. Numeric variables, literals, and database columns can be put into number (decimal, float, integer) fields. String variables, literals, and database columns can be put into char, text, or date fields. Date variables can be put into date, char, or text fields.

Example

In the following example, the four variables &name, #count, $date1, and $code are placed in the first four fields defined in the names array. The data is put into the #j th element of the array.

put  &name  #count $date1  $code  into  names(#j)

The following command places #j2, #j3, and #j4 into the zero through 2nd occurrences of the tot field in the #j th element of the totals array.

put  #j2  #j3  #j4  into  totals(#j)  tot(0)  tot(1)  tot(2)

The following command copies #count into the #j2 th occurrence of the count field in the #j th element of the states array.

put  #count  into  states(#j)  count(#j2)

Considerations for Using PUT

When a date variable or column is moved into a text or char array field, the date is converted to a string according to the following rules:

  • For DATETIME columns and SQR DATE variables, SQR uses the format specified by the SQR_DB_DATE_FORMAT setting.

    If this has not been set, SQR uses the first database-dependent format as listed in the Default Database Formats table.

  • For DATE columns, SQR uses the format specified by the SQR_DB_DATE_ONLY_FORMAT setting.

    If this has not been set, SQR uses the format listed in the DATE Column Formats table.

  • For TIME columns, SQR uses the format specified by the SQR_DB_TIME_ONLY_FORMAT setting.

    If this has not been set, SQR uses the format as listed in the TIME Column Formats table.

When a string variable, column, or literal is moved to a date array field, the string must be in the format specified by the SQR_DB_DATE_FORMAT setting, one of the database-dependent formats as listed in the DATE Column Formats table is used, or the database-independent format 'SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]' is used.

dst_array_name(element)

If array fields are listed, data is placed into each field in the sequence in which it is listed, in the occurrence specified for that field.

If array fields are not listed, data is placed into consecutive fields in the order in which they were defined in the CREATE-ARRAY command; data is copied into occurrence zero of each field of the element specified in the array.

 field [ ( occurs ) ]

Array element and field occurrence numbers can be numeric literals (123) or numeric variables (#j).

If no occurrence is specified, occurrence zero is used.