Copy data from Temp Table

Hi there,

This should be quite easy but I'm having trouble in doing it.

I copied data to a Temp Table with a primary key and added Fields.

Now I want to transfer that data back to the original table since that data was lost in the upgrade.

I just want to transfer the fields with the same key number to the original table

    local procedure TempCustomer_DataCopy()
    var
        DestinyTable: Record Customer;
        OriginTable: Record "Customer Temp";
    begin
        With OriginTable do begin
            if FindSet() then
                repeat
                    DestinyTable.Init();
                    DestinyTable.Transferfields(originTable);
                    DestinyTable.Insert;
                until next = 0;
        end;
    end;

Parents
  • Hello 

    Four things: If the Customer Temp table is the same as the Customer table but only a different Table ID then you should use Transferfields. Secondly dont use WITH when it comes to tables, Thirdly when using FINDSET always deside weather how you want to use it eg. like FINDSET(FALSE,FALSE). Lastly whenever you use a INSERT, MODIFY or DELETE you have to actively decide if you need (TRUE) or (FALSE) - In most cases it should be INSERT(TRUE);

    Your code should then look like this

    Local procedure TempCustomer_DataCopy()
        var
            DestinyTable: Record Customer;
            OriginTable: Record "Customer Temp";
        begin
            if OriginTable.FindSet(FALSE,FALSE) then
            repeat
                DestinyTable.Init();
                DestinyTable.Transferfields(originTable);
                DestinyTable.Insert(TRUE);
            until OriginTable.next = 0;
        end;

Reply Children
No Data
Related
Recommended