Simple Insert problem.. already exists

Hello togheter,
I have two tables 50000 and 50001 both has the fields “Name” and “Description”.
I wanna Copy all records from the the first table to the second, but it works only with the Field “Name”. somebody knows why?


field1 := RecordRef1.FIELD(2); // works only with 1
field2 := RecordRef2.FIELD(2); // works only with 1
field2.VALUE := field1.VALUE;
UNTIL RecordRef1.NEXT = 0;

get the Error (translated by me to english) “‘table2’ exists already. Identified Fields and Values: Name=”
Any Ideas, Tipps?

What is the Primary keys of your tables?

Thanks for answering… almost gave up… [;)]

The Name Field is the PK, i know the issue has something to do with this PK

Well it say it’s trying to insert an empty value and that this empty value already exists. The error happens on the INSERT line.

I assume that your “Name” field is field number 2? Otherwise then I would change RecordRef1.FIELD(2) to RecordRef1.FIELD(1) or whatever field number your name fields has.

Name is the first Field and Description is the second field…

Yes if i make RecordRef1.FIELD(1) it works, and it succesfully copys the Names from the first table to the second.

But what if i want to copy the Description Fields?

Ok. But you must do the same thing for the other fields also. What you do now will only set the Description and no Name.

Try with this:

IF RecordRef1.FIND('-') THEN REPEAT field1 := RecordRef1.FIELD(1); field2 := RecordRef2.FIELD(1); field2.VALUE := field1.VALUE; field1 := RecordRef1.FIELD(2); field2 := RecordRef2.FIELD(2); field2.VALUE := field1.VALUE; RecordRef2.INSERT; UNTIL RecordRef1.NEXT = 0;

Ok this works now to Copy both Fields at the same time… but what if lets say i already copied Field No 1 (Name) and only want to Copy the Field No 2 (Description)?

Well then you need to retrieve the record and modify instead of inserting.

aaah i did forget that… thanks very very very much [:D][:D][:D]

Mhm Still got a last question [:$] but i’m starting to understand…

Now what if i dont just want to Copy a single Field, isnt there a way i can Copy the whole Record at once?

somehow like this:

RecordRef2 := RecordRef1;
UNTIL RecordRef1.NEXT = 0;

No. You need to go through all the fields one by one when using recordref/fieldref.

But you can do by using the Field table as a “pointer” and filter on all “normal” fields (exclude Flow Fields and Flow Filters).

Ok Thanks you very much, i am now [:#] maybe for the next 20 mins [:P]