John Cosmas
2005-07-21 05:07:57 UTC
I have a situation where I'm trying to fetch data from multiple tables. I
get the records I want from the first, scan through each record, and then
fetch the child records from another table based on the values from the
first table. This obviously uses a nested statement. Please review the
enclosed and let me know if I'm heading down the right path.
SELECT 0
USE "C:\Program Files\GIM Editor\wrk_policy.dbf" SHARED AGAIN
SELECT 1
USE "E:\GIMS\Database\car_stat.dbf" SHARED AGAIN
SELECT 2
USE "C:\Program Files\GIM Editor\wrk_car_stat.dbf" SHARED AGAIN
SCAN
SCATTER MEMVAR
? wrk_policy.k4
? wrk_policy.a
SELECT * FROM car_stat WHERE ;
car_stat.k4 = wrk_policy.k4 AND car_stat.a = wrk_policy.a
SCATTER MEMVAR
INSERT INTO wrk_car_stat FROM MEMVAR
ENDSCAN
USE
This code does not currently run. I can see the records from the first
table (wrk_policy), but I haven't seen it run the SELECT and populate the
second table. Any help in this matter would be most appreciated.
John
get the records I want from the first, scan through each record, and then
fetch the child records from another table based on the values from the
first table. This obviously uses a nested statement. Please review the
enclosed and let me know if I'm heading down the right path.
SELECT 0
USE "C:\Program Files\GIM Editor\wrk_policy.dbf" SHARED AGAIN
SELECT 1
USE "E:\GIMS\Database\car_stat.dbf" SHARED AGAIN
SELECT 2
USE "C:\Program Files\GIM Editor\wrk_car_stat.dbf" SHARED AGAIN
SCAN
SCATTER MEMVAR
? wrk_policy.k4
? wrk_policy.a
SELECT * FROM car_stat WHERE ;
car_stat.k4 = wrk_policy.k4 AND car_stat.a = wrk_policy.a
SCATTER MEMVAR
INSERT INTO wrk_car_stat FROM MEMVAR
ENDSCAN
USE
This code does not currently run. I can see the records from the first
table (wrk_policy), but I haven't seen it run the SELECT and populate the
second table. Any help in this matter would be most appreciated.
John