It is a query that correctly works with only an insert in the loop,
but it doesn't work with the second insert statement (insert into
select).
Can you help me? Thank you.
a = 0
SELECT MAX(Fatspe.cod_fatt) AS max_a;
FROM ;
fatspe;
INTO CURSOR cur_a
select cur_a
go top
a = cur_a.max_a
select b.cod_fatt, b.num_fatt, b.data_fatt, b.tot_fatt, b.imp_iva_fa,
b.cod_fornit, b.iva_fatt, b.impon_fatt, b.data_scad_ into cursor
cur_appo ;
FROM query_fatspe_dvd b
select cur_appo
go top
do while not eof()
a = a+1
INSERT INTO fatspe values (a, cur_appo.num_fatt, cur_appo.data_fatt,
cur_appo.tot_fatt, cur_appo.imp_iva_fa, cur_appo.cod_fornit,
cur_appo.iva_fatt, cur_appo.impon_fatt, cur_appo.data_scad_)
INSERT INTO carico SELECT a, c.cod_barre, c.costo, c.qta_carico,
c.filler FROM query_carico_dvd c WHERE c.cod_fatt = cur_appo.cod_fatt
select cur_appo
skip
loop
enddo
select cur_appo
use
> INSERT INTO carico SELECT a, c.cod_barre, c.costo, c.qta_carico,
> c.filler FROM query_carico_dvd c WHERE c.cod_fatt = cur_appo.cod_fatt
Just a guess: maybe foxpro does not like that WHERE clause (but it should!).
Maybe store the value of cur_appo.cod_fatt to a variable and compare with this
variable.
Hth
Bernhard Sander