Need some help on Import and updating some data I have two tables that I need to update I can update the main table fine using code below, my problem is updating the child records ITEMS.
I have 2 tables MAIN & ITEMS main holds basic information and ITEMS holds items and notes. I import from 2 temp tables tempmain & tempitems , that can either have new records or existing records, if they are existing they will need to update the existing records. But just cannot work out how to update the Items. – main is no problem the child records is my problem.
Structure….. The temp table is exactly the same structure
MAIN
ma_pk
ma_fname
ma_sname
ITEMS
It_pk
It_ma_fk
It_Item
it_notes
SELECT tempmain
SCAN
lnclaimno=UPPER(claimno)
lnpk=pk
lnamount=amount
IF INDEXSEEK(lnclaimno,.T.,'main','claimno')
SELECT MAIN
REPLACE fname WITH tempmain.fname
REPLACE sname WITH tempmain.sname
ELSE && append a new records !
SELECT MAIN
APPEND FROM tempmain FOR claimno = lnclaimno
SELECT items
APPEND FROM tempitems FOR main_fk = lnpk
ENDIF
ENDSCAN
Any suggestion how I can update the Items Table, as there might already be 20 items and only one need to be update – the only way to find a match would be by it_item and it_ma_fk
Thanks
Paul
I have 2 tables MAIN & ITEMS main holds basic information and ITEMS holds items and notes. I import from 2 temp tables tempmain & tempitems , that can either have new records or existing records, if they are existing they will need to update the existing records. But just cannot work out how to update the Items. – main is no problem the child records is my problem.
Structure….. The temp table is exactly the same structure
MAIN
ma_pk
ma_fname
ma_sname
ITEMS
It_pk
It_ma_fk
It_Item
it_notes
SELECT tempmain
SCAN
lnclaimno=UPPER(claimno)
lnpk=pk
lnamount=amount
IF INDEXSEEK(lnclaimno,.T.,'main','claimno')
SELECT MAIN
REPLACE fname WITH tempmain.fname
REPLACE sname WITH tempmain.sname
ELSE && append a new records !
SELECT MAIN
APPEND FROM tempmain FOR claimno = lnclaimno
SELECT items
APPEND FROM tempitems FOR main_fk = lnpk
ENDIF
ENDSCAN
Any suggestion how I can update the Items Table, as there might already be 20 items and only one need to be update – the only way to find a match would be by it_item and it_ma_fk
Thanks
Paul