DYNAMIC ARRAY.copyTo

Copies a complete array to the destination array passed as parameter.

Syntax

copyTo( dst dynamic-array-type )
  1. dst is the destination dynamic array, with the same type definition as the source array.
  2. dynamic-array-type is a DYNAMIC ARRAY OF ... type that corresponds to the source array.

Usage

The copyTo() method copies all elements of the source array into the destination array.

The method truncates the length of the destination array to the length of the source array.

If the destination array is not of the same type as the source array, error -8112 is thrown.

Important: Avoid making a copy of huge arrays, consider using a database temporary table instead.

Example

MAIN
    TYPE t_names RECORD
             num INT,
             name STRING
         END RECORD
    DEFINE aa, ab DYNAMIC ARRAY OF t_names
    LET aa[1].num = 101
    LET aa[1].name = "Mike Tormme"
    CALL aa.copyTo(ab)
    DISPLAY ab[1].*
END MAIN