Regards.
I'm having an issue with a small code working with ODBC connection.
I'm using SQLEXCEC to select information form a table to a cursor, but once I need to use the cursor it can't be found.
This is part of the code:
**USE C:\PagosUniRed_SQL\TAbonos1.dbf ALIAS TAbonos1 IN SELECT(0) SHARED
GO TOP IN TAbonos1
DO WHILE !EOF("TAbonos1")
* Selecciona los datos del abono/ Select payment data
SQLEXEC(lc_con,"SELECT * FROM dbo.admDocumentos WHERE CIDDOCUMENTO = TAbonos1.CIDDOCUMENTOABONO and CIDDOCUMENTODE in(7,9,10,12)","TDoctos1")
* Seleccion los datos del cargo/ Select invoice data
SQLEXEC(lc_con,"SELECT * FROM dbo.admDocumentos WHERE CIDDOCUMENTO = TAbonos1.CIDDOCUMENTOCARGO and CIDDOCUMENTODE =4","TDoctos2")
* Inserta los datos al cursor TRelacion / Inserts the data to cursor TRelacion
lCantPagos = RECCOUNT("TDoctos1")
lCantFacturas= RECCOUNT("TDoctos2")
IF (lCantPagos > 0) THEN
IF (lCantFacturas>0) THEN
INSERT INTO TRelacion (pdocumde, pfolio, pserie, pfecha, pabonado, pmoneda, ptc,ffolio, fserie, ftotal, frefe ) VALUES (TDoctos1.CIDDOCUMENTODE, TDoctos1.CFOLIO, TDoctos1.CSERIEDOCUMENTO, TDoctos1.CFECHA, TAbonos1.CIMPORTEABONO, TDoctos1.CIDMONEDA, TDoctos1.CTIPOCAMBIO, TDoctos2.CFOLIO, TDoctos2.CSERIEDOCUMENTO, TDoctos2.CTOTAL, TDoctos2.CREFERENCIA)
ENDIF
ENDIF
SKIP IN TAbonos1
ENDDO
SQLDISCONNECT(lc_con)
As you can see, I'm selecting some fields from a previous cursor named TAbonos, and in each selection I created a cursor, TDoctos1 and TDoctos2.
The error comes out when I try to reccount TDoctos1 in variable lCantPagos.
May be I'm doing something wrong.
I attach the full code and a couple of images of the error and trace.
I'm having an issue with a small code working with ODBC connection.
I'm using SQLEXCEC to select information form a table to a cursor, but once I need to use the cursor it can't be found.
This is part of the code:
**USE C:\PagosUniRed_SQL\TAbonos1.dbf ALIAS TAbonos1 IN SELECT(0) SHARED
GO TOP IN TAbonos1
DO WHILE !EOF("TAbonos1")
* Selecciona los datos del abono/ Select payment data
SQLEXEC(lc_con,"SELECT * FROM dbo.admDocumentos WHERE CIDDOCUMENTO = TAbonos1.CIDDOCUMENTOABONO and CIDDOCUMENTODE in(7,9,10,12)","TDoctos1")
* Seleccion los datos del cargo/ Select invoice data
SQLEXEC(lc_con,"SELECT * FROM dbo.admDocumentos WHERE CIDDOCUMENTO = TAbonos1.CIDDOCUMENTOCARGO and CIDDOCUMENTODE =4","TDoctos2")
* Inserta los datos al cursor TRelacion / Inserts the data to cursor TRelacion
lCantPagos = RECCOUNT("TDoctos1")
lCantFacturas= RECCOUNT("TDoctos2")
IF (lCantPagos > 0) THEN
IF (lCantFacturas>0) THEN
INSERT INTO TRelacion (pdocumde, pfolio, pserie, pfecha, pabonado, pmoneda, ptc,ffolio, fserie, ftotal, frefe ) VALUES (TDoctos1.CIDDOCUMENTODE, TDoctos1.CFOLIO, TDoctos1.CSERIEDOCUMENTO, TDoctos1.CFECHA, TAbonos1.CIMPORTEABONO, TDoctos1.CIDMONEDA, TDoctos1.CTIPOCAMBIO, TDoctos2.CFOLIO, TDoctos2.CSERIEDOCUMENTO, TDoctos2.CTOTAL, TDoctos2.CREFERENCIA)
ENDIF
ENDIF
SKIP IN TAbonos1
ENDDO
SQLDISCONNECT(lc_con)
As you can see, I'm selecting some fields from a previous cursor named TAbonos, and in each selection I created a cursor, TDoctos1 and TDoctos2.
The error comes out when I try to reccount TDoctos1 in variable lCantPagos.
May be I'm doing something wrong.
I attach the full code and a couple of images of the error and trace.