Difference between COPY, TRANSFERFIELDS and :=

Hi all,

Could somebody please provide me with some details about the differences between the various methods of assigning record variables?

I know that COPY also copies marks, filters and keys, while TRANSFERFIELDS can be used with records of different tables - but are there any specific (dis-)advantages for each method? Is there anything special about the simple assignment operator? Is there a way to copy entire ranges of records, or do I always have to loop over the filtered range?

Thanx,
  • TRANSFERFIELDS only copies the fields that match with fieldnumber, format and length (if code or text)
    This can be used by similar tables (we use this for moving telephone-call-data (CDRs) from one table to another, where most of the fields are equal (date, time, calling number and so on) and some are different (often technical details)).

    COPY copies the whole record. I use this for making a copy of customer-calls into a safty-company.

    The ":=" assigns only one value to one field.

    Nevertheless you have to loop through the records if you want to copy more than one record or field.
  • quote:
    The ":=" assigns only one value to one field.


    You could also assign whole Records with ":=" !
    e.g. Codeunit 80
    ...
    VerkKopf := Rec;
    ...
    where both (VerkKopf and Rec) are variables of the same type (T36).

    As an example for TRANSFERFIELDS have a look at CU 80, where the FIELDS of VerkZeile (T37) are TRANSFERED to VerkLiefZeile (T111).

    Regards,
    Jörg
  • COPY also includes filters, marks and keys.

    DjangMan
  • Thanks a lot folks!

    So, do I take it that COPY and := are roughly equivalent?
  • No := will make one record variable point to the same record.

    Copy does this and also includes the filters, marks and keys.


    Paul Baxter
  • Paul, what do you mean by "point to..."? Are you saying that no physical copying of data is involved, just like pointer assignment in C/C++?
  • No Navision always uses copies of records.
    It read from the data base when you do a GET, FIND or NEXT and writes to a database when you MODIFY or INSERT. All other times it is just a copy of what is in the database. So you can GET a record, and change the field values but the database is not changed until you do a MODIFY. Other users will not see this change until you do a COMMIT (although chances are that the table will be locked until then any way).


    But a Record is more than just a copy of a record in the database; it has an active key, filters and marks. Each record (and form, report and dataport) is indipendant to any other. So because you set a filter does affect the other users of the database.

    So := will only copy the actual field values

    but COPY will copy the view information as well.

    Paul Baxter
  • Ok, that makes it clear. Thanks a lot!
Related
Recommended