Copy tables filtering data

mikelcid

New Member
Hi all!

I want to copy the data from one table to another one but filtering the data.

Imagine that I have the Customer table from sports2000 and I want to have in another table the same table but only with CustNum = 2.

How can I do that?
 
Take a look at the BUFFER-COPY statement - it copies fields per your definition from a source buffer into a target buffer. Still you need to code the logic to fetch the records into the source buffer and to create the target buffer:

Coded in notepad IDE, therefore not syntax checked:
FOR EACH SourceBuffer NO-LOCK WHERE ...:

CREATE TargetBuffer.
BUFFER-COPY SourceBuffer TO TargetBuffer.

END.

Heavy Regards, RealHeavyDude.
 
do table-1 and table-2 have same field's? Are you always adding records to table-2 or will you also update existing table-2 records?

simple approach whould be to

loop through your first table in for each ..
a . with a WHERE (to filter records ) ..
b. OR inside the for each.... write code to filter your data

then use BUFFER-COPY to copy from table-1 to table-2.

you can also dump table-1 records to a file. Import data from file to temp-table. Do all validation/filter on temp-table... then copy from temp-table to table-2.
 
Back
Top