Problema Recorset oRs:RecordCount() (SOLUCIONADO)

Problema Recorset oRs:RecordCount() (SOLUCIONADO)

Postby leandro » Mon Jan 25, 2021 3:42 pm

Buenos días para todos, hoy me salió un error al momento de intentar contar la cantidad de registros que tiene un recorset. La consulta que estoy haciendo contiene la clausula LEFT JOIN, no se si sea por eso, lo raro es que tengo muchas de las consultas en la aplicación tienen esta clausula y funcionan bien.

La consulta:

Code: Select all  Expand view  RUN

//CONSULTA DEL RESUMEN DE LAS FACTURAS POR CAJA Y FECHA
cQry:="SELECT FAC.ll_cajare,ll_fechas,"+;
"IFNULL(SUM(MOV.mm_subtot),0) AS subtotal,"+;
"IFNULL(SUM(MOV.mm_basiva),0) AS base,"+;
"IFNULL(SUM(MOV.mm_valiva),0) AS iva,"+;
"IFNULL(SUM(MOV.mm_totale),0) AS total "+;
"FROM ("+oLamcla:tFact+" FAC) "+;
"LEFT JOIN "+oLamcla:tMofa+" MOV ON FAC.ll_docume=MOV.mm_docume AND FAC.ll_consec=MOV.mm_consec "+;
"WHERE FAC.ll_cajare='"+alltrim(cCjaActiva)+"' AND FAC.ll_fechas='"+dtos(dFechaDia)+"' AND FAC.ll_anulad<>'A'"
oRs := FW_OPENRECORDSET(oCnCja,cQry,adLockOptimistic,adOpenKeyset)
NrEG := oRs:RecordCount()
 


El error:
Code: Select all  Expand view  RUN

Application
===========
   Path and name: C:\DLYMA\dlyma.exe (32 bits)
   Size: 6,552,576 bytes
   Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613)
   FiveWin  version: FWH 19.09
   C compiler version: Borland/Embarcadero C++ 7.3 (32-bit)
   Windows version: 6.2, Build 9200

   Time from start: 0 hours 0 mins 29 secs
   Error occurred at: 25/01/2021, 10:14:45
   Error description: Error ADODB.RecordSet/6  DISP_E_UNKNOWNNAME: RECORDCOUNT
   Args:

Stack Calls
===========
   Called from:  => TOLEAUTO:RECORDCOUNT( 0 )
   Called from: z:\prg\R32_caja.prg => PCIERRE( 1614 )
   Called from: z:\prg\R32_caja.prg => (b)FOPCIONCAJA( 908 )
   Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 704 )
   Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 990 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1791 )
   Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 2030 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3559 )
   Called from:  => WINRUN( 0 )
   Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 1097 )
   Called from: z:\prg\R32_menu.prg => VTNAPRINCIPAL( 550 )
   Called from: z:\prg\R32_menu.prg => MAIN( 90 )
 


Si cambio la consulta sin la relación LEFT JOIN si me devuelve correctamente el valor 0
Code: Select all  Expand view  RUN

cQry:="SELECT * FROM tbl_fact WHERE ll_consec='777777777'"
 


De antemano gracias
Last edited by leandro on Mon Jan 25, 2021 4:12 pm, edited 1 time in total.
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1676
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Problema Recorset oRs:RecordCount()

Postby leandro » Mon Jan 25, 2021 3:58 pm

Parece que ya encontre la solución, el problema es que el recorset que devuelve tiene en el primer campo un registro null.

Image

Lo solucione de la siguiente manera:

Code: Select all  Expand view  RUN

SELECT IFNULL(FAC.ll_cajare,''),IFNULL(ll_fechas,''),"+;
"
IFNULL(SUM(MOV.mm_subtot),0) AS subtotal,"+;
"
IFNULL(SUM(MOV.mm_basiva),0) AS base,"+;
"
IFNULL(SUM(MOV.mm_valiva),0) AS iva,"+;
"
IFNULL(SUM(MOV.mm_totale),0) AS total "+;
"
FROM ("+oLamcla:tFact+" FAC) "+;
"
LEFT JOIN "+oLamcla:tMofa+" MOV ON FAC.ll_docume=MOV.mm_docume AND FAC.ll_consec=MOV.mm_consec "+;
"
WHERE FAC.ll_cajare='"+alltrim(cCjaActiva)+"' AND FAC.ll_fechas='"+dtos(dFechaDia)+"' AND FAC.ll_anulad<>'A'
 
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1676
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 87 guests