Problem with copy records from table

i want to copy records from table this is my code 

private void copy()
table table1 , table2;
VendInvoiceInfoLine VendInvoiceInfoLine;
PurchLine PurchLine;

PurchLine = PurchLine::findRecId(VendInvoiceInfoLine.purchlinerecid);

while select table1 
where table1 .purchlinerefrecid == PurchLine.recid
table2.Account = anal1.Account;
table2.Type = table1 .Type;
table2.Percent = table1 .Percent;
table2.Refrecidvend= VendInvoiceInfoLine.RecId;

the result in table 2 is the duplication 

account     type      percent

1                 objet      10%

1                objet       10%
 and if i delete record from table2 it will be deleted from table1

  • Hi Wafa,

    I can't see two different table in your code. Only i can see that you are trying to copy same record in the same table.

    And even there is no different in record as well. So its obvious system is performing his work.

    private void copy()
    table table1 , table2;

    Please re-verify your requirement.

    Thanks and regards

    Rohit Ahmed