Relacion de tablas
Hola buen día ya tengo grabado registros de tres tablas en el archivo temporal, me falta grabar registros de la ultima tabla (TablaE) q sucede q esta tabla tiene en sus campos uno q es inscrinrx y otro q es facnro, el campo inscrinrx se relaciona con la tabla conexion.inscrinrn y el campo facnro se relaciona con la tabla notas1.notnro como hago para grabar los registros del tablaE en el archivo temporal.
SELECT * FROM ("d:\pruebas\sici\catastro\totfac");
INTO CURSOR cTablaA;
WHERE MONTH(facemifec)=nMes AND YEAR(facemifec)=nAño AND MONTH(facvenfec)=nMes AND YEAR(facvenfec)=nAño;
order BY facnro
INDEX ON facnro TAG cTablaA ADDITIVE
SELECT * FROM ("d:\pruebas\sici\sfactura");
INTO CURSOR cTablaB;
WHERE MONTH(fscfecv)=nMes AND YEAR(fscfecv)=nAño
INDEX ON inscrinrx TAG cTablaB ADDITIVE
SELECT * FROM ("d:\pruebas\sici\catastro\notas");
INTO CURSOR cTablaC;
WHERE MONTH(notfecha)=nMes AND YEAR(notfecha)=nAño ORDER BY inscrinrn
INDEX ON inscrinrn TAG cTablaC ADDITIVE
SELECT * FROM ("d:\pruebas\sici\catastro\conexion");
INTO CURSOR cTablaD ORDER BY inscrinro
INDEX ON inscrinro TAG cTablaD ADDITIVE
SELECT("cTablaA")
SCAN
IF !SEEK(cTablaA.facnro,"cTemp","codigo")
APPEND BLANK IN cTemp
replace cTemp.fec_emi WITH cTablaA.facemifec;
cTemp.fec_venc WITH cTablaA.facvenfec;
cTemp.tipo WITH "14";
cTemp.serie WITH cTablaA.facsernro;
cTemp.numero WITH cTablaA.facnro
IF Seek(ALLTRIM(cTablaA.inscrinrx),"cTablaD")
IF !EMPTY(cTablaD.clirucx)
replace cTemp.tipo_doc WITH "6"
replace cTemp.num_doc WITH cTablaD.clirucx
ELSE
IF !EMPTY(cTablaD.clilelx)
replace cTemp.tipo_doc WITH "1"
replace cTemp.num_doc WITH cTablaD.clilelx
ENDIF
ENDIF
ENDIF
replace cTemp.cliente WITH IIF( Seek(ALLTRIM(cTablaA.inscrinrx),"cTablaD"), Subst(Alltrim (cTablaD.clinomx),1,40), "No Existe Cliente")
replace cTemp.total WITH cTablaA.factotal
ENDIF
ENDSCAN
SELECT("cTablaB")
SCAN FOR fscsernro=4 AND fscestado=2
IF !SEEK(cTablaB.inscrinrx,"cTemp","codigo")
APPEND BLANK IN cTemp
replace cTemp.fec_emi WITH cTablaB.fscfech;
cTemp.fec_venc WITH cTablaB.fscfecv;
cTemp.tipo WITH "14";
cTemp.serie WITH cTablaB.fscsernro;
cTemp.numero WITH cTablaB.fscnro
IF Seek(ALLTRIM(cTablaB.inscrinrx),"cTablaD")
IF !EMPTY(cTablaD.clirucx)
replace cTemp.tipo_doc WITH "6"
replace cTemp.num_doc WITH cTablaD.clirucx
ELSE
IF !EMPTY(cTablaD.clilelx)
replace cTemp.tipo_doc WITH "1"
replace cTemp.num_doc WITH cTablaD.clilelx
ENDIF
ENDIF
ENDIF
replace cTemp.cliente WITH IIF( Seek(ALLTRIM(cTablaB.inscrinrx),"cTablaD"), Subst(Alltrim (cTablaD.clinomx),1,40), "No Existe Cliente")
replace cTemp.total WITH cTablaB.fscsub
ENDIF
ENDSCAN
SELECT("cTablaB")
SCAN FOR fscsernro=2 AND fscestado<>3
IF !SEEK(cTablaB.inscrinrx,"cTemp","codigo")
APPEND BLANK IN cTemp
replace cTemp.fec_emi WITH cTablaB.fscfech;
cTemp.fec_venc WITH cTablaB.fscfecv;
cTemp.tipo WITH "14";
cTemp.serie WITH cTablaB.fscsernro;
cTemp.numero WITH cTablaB.fscnro
IF Seek(ALLTRIM(cTablaB.inscrinrx),"cTablaD")
IF !EMPTY(cTablaD.clirucx)
replace cTemp.tipo_doc WITH "6"
replace cTemp.num_doc WITH cTablaD.clirucx
ELSE
IF !EMPTY(cTablaD.clilelx)
replace cTemp.tipo_doc WITH "1"
replace cTemp.num_doc WITH cTablaD.clilelx
ENDIF
ENDIF
ENDIF
replace cTemp.cliente WITH IIF( Seek(ALLTRIM(cTablaB.inscrinrx),"cTablaD"), Subst(Alltrim (cTablaD.clinomx),1,40), "No Existe Cliente")
replace cTemp.total WITH cTablaB.fscsub
ENDIF
ENDSCAN
close datab
SELECT * FROM ("d:\pruebas\sici\catastro\totfac");
INTO CURSOR cTablaA;
WHERE MONTH(facemifec)=nMes AND YEAR(facemifec)=nAño AND MONTH(facvenfec)=nMes AND YEAR(facvenfec)=nAño;
order BY facnro
INDEX ON facnro TAG cTablaA ADDITIVE
SELECT * FROM ("d:\pruebas\sici\sfactura");
INTO CURSOR cTablaB;
WHERE MONTH(fscfecv)=nMes AND YEAR(fscfecv)=nAño
INDEX ON inscrinrx TAG cTablaB ADDITIVE
SELECT * FROM ("d:\pruebas\sici\catastro\notas");
INTO CURSOR cTablaC;
WHERE MONTH(notfecha)=nMes AND YEAR(notfecha)=nAño ORDER BY inscrinrn
INDEX ON inscrinrn TAG cTablaC ADDITIVE
SELECT * FROM ("d:\pruebas\sici\catastro\conexion");
INTO CURSOR cTablaD ORDER BY inscrinro
INDEX ON inscrinro TAG cTablaD ADDITIVE
SELECT("cTablaA")
SCAN
IF !SEEK(cTablaA.facnro,"cTemp","codigo")
APPEND BLANK IN cTemp
replace cTemp.fec_emi WITH cTablaA.facemifec;
cTemp.fec_venc WITH cTablaA.facvenfec;
cTemp.tipo WITH "14";
cTemp.serie WITH cTablaA.facsernro;
cTemp.numero WITH cTablaA.facnro
IF Seek(ALLTRIM(cTablaA.inscrinrx),"cTablaD")
IF !EMPTY(cTablaD.clirucx)
replace cTemp.tipo_doc WITH "6"
replace cTemp.num_doc WITH cTablaD.clirucx
ELSE
IF !EMPTY(cTablaD.clilelx)
replace cTemp.tipo_doc WITH "1"
replace cTemp.num_doc WITH cTablaD.clilelx
ENDIF
ENDIF
ENDIF
replace cTemp.cliente WITH IIF( Seek(ALLTRIM(cTablaA.inscrinrx),"cTablaD"), Subst(Alltrim (cTablaD.clinomx),1,40), "No Existe Cliente")
replace cTemp.total WITH cTablaA.factotal
ENDIF
ENDSCAN
SELECT("cTablaB")
SCAN FOR fscsernro=4 AND fscestado=2
IF !SEEK(cTablaB.inscrinrx,"cTemp","codigo")
APPEND BLANK IN cTemp
replace cTemp.fec_emi WITH cTablaB.fscfech;
cTemp.fec_venc WITH cTablaB.fscfecv;
cTemp.tipo WITH "14";
cTemp.serie WITH cTablaB.fscsernro;
cTemp.numero WITH cTablaB.fscnro
IF Seek(ALLTRIM(cTablaB.inscrinrx),"cTablaD")
IF !EMPTY(cTablaD.clirucx)
replace cTemp.tipo_doc WITH "6"
replace cTemp.num_doc WITH cTablaD.clirucx
ELSE
IF !EMPTY(cTablaD.clilelx)
replace cTemp.tipo_doc WITH "1"
replace cTemp.num_doc WITH cTablaD.clilelx
ENDIF
ENDIF
ENDIF
replace cTemp.cliente WITH IIF( Seek(ALLTRIM(cTablaB.inscrinrx),"cTablaD"), Subst(Alltrim (cTablaD.clinomx),1,40), "No Existe Cliente")
replace cTemp.total WITH cTablaB.fscsub
ENDIF
ENDSCAN
SELECT("cTablaB")
SCAN FOR fscsernro=2 AND fscestado<>3
IF !SEEK(cTablaB.inscrinrx,"cTemp","codigo")
APPEND BLANK IN cTemp
replace cTemp.fec_emi WITH cTablaB.fscfech;
cTemp.fec_venc WITH cTablaB.fscfecv;
cTemp.tipo WITH "14";
cTemp.serie WITH cTablaB.fscsernro;
cTemp.numero WITH cTablaB.fscnro
IF Seek(ALLTRIM(cTablaB.inscrinrx),"cTablaD")
IF !EMPTY(cTablaD.clirucx)
replace cTemp.tipo_doc WITH "6"
replace cTemp.num_doc WITH cTablaD.clirucx
ELSE
IF !EMPTY(cTablaD.clilelx)
replace cTemp.tipo_doc WITH "1"
replace cTemp.num_doc WITH cTablaD.clilelx
ENDIF
ENDIF
ENDIF
replace cTemp.cliente WITH IIF( Seek(ALLTRIM(cTablaB.inscrinrx),"cTablaD"), Subst(Alltrim (cTablaD.clinomx),1,40), "No Existe Cliente")
replace cTemp.total WITH cTablaB.fscsub
ENDIF
ENDSCAN
close datab
1 Respuesta
Respuesta de Cesar Enrique Yamunaque Baca
1