Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP 7 Insert into table1 if table2 has additional record 1

Status
Not open for further replies.

bettyfurr

Technical User
Mar 12, 2002
371
US
This is what I want to do. I want to

SCAN FOR agcympep.org_cli_cd <> agcyinfo.org_cli_cd
and then do an insert if agcympep table when it does not have the record that exist in agcyinfo.

INSERT INTO agcympep (org_id,org_cli_cd,org_nm,addr_ln1_n,addr_ln2_n,addr_ln3_n,addr_ln4_n,;
city_nm,st_cd,zip_cd,zip_plus4_,county,members);
VALUES (agcyinfo.org_id,org_cli_cd,agcyinfo.org_nm,;
agcyinfo.addr_ln1_n,agcyinfo.addr_ln2_n,agcyinfo.addr_ln3_n,agcyinfo.addr_ln4_n,;
agcyinfo.city_nm,agcyinfo.st_cd,agcyinfo.zip_cd,agcyinfo.zip_plus4_,;
agcyinfo.county,agcyinfo.members);

loop

endscan

This logic causes an inserting into agcympep after each read of agcyinfo of the 1st record in agcyinfo.

I had 870+ records in agcympep and after this logic, I had 1750+ records where every other one of records were the 1st record in the table.

Please help.

Betty :-(

 
You don't specify which table is selected before starting your SCAN, so I can't tell which table you're moving the record pointer in, but without moving it in the agcyinfo table, you'll always get the first record.

Try something like:
Code:
SELECT agcyinfo
SCAN 
   IF !SEEK( agcympep.org_cli_cd )
       INSERT INTO agcympep.....
   ENDIF
ENDSCAN


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Thank you,

Betty :)

Sometimes we can not see the forest for the trees.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top