DICTIONARY.copyTo

Copies all elements of the dictionary into another dictionary.

Syntax

copyTo( dst dictionary-type )
  1. dst is the destination dictionary, with the same type definition as the source dictionary.
  2. dictionary-type is a DICTIONARY OF ... type that corresponds to the source dictionary.

Usage

The copyTo() method clones the complete dictionary into the destination dictionary passed as parameter.

The destination dictionary will be cleared before the copy operation starts.

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

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

Example

MAIN
    TYPE t_contact RECORD
             name STRING,
             address STRING,
             brith DATE
         END RECORD
    DEFINE d1, d2 DICTIONARY OF t_contact

    LET d1["Kirk"].name = "James T. Kirk"
    LET d1["Kirk"].address = "Riverside, Iowa"

    LET d1["Spock"].name = "Spock"
    LET d1["Spock"].address = "Shi'Kahr"

    CALL d1.copyTo(d2)

    DISPLAY d2.getLength()
    DISPLAY d2["Spock"].*

END MAIN