Tengo una consulta donde intervienen varios archivos y de ahí, escojo ciertas columnas para mostrar en un Browse sencillo, pero no muestra nada. Dice "No se encontraron registros coincidentes"
Este es el código:
- Code: Select all Expand view RUN
- function main()
LOCAL o, oRs, hRes,oBrw,oo
local oCol
local aRows := {}
oo := WDO():Rdbms( 'MYSQL', "127.0.0.1", "root", "123456", "indfundacion", 3307 )
IF oo:lConnect
? 'Connected !', '<b>Versión RDBMS MySql', oo:Version()
ELSE
? oo:cError
ENDIF
cSql = "SELECT IFNULL(contrib.CODIGO, ' ') AS CODIGO,IFNULL(contrib.razon, ' ') AS RAZON ,IFNULL(contrib.direcc, ' ') AS DIRECCION,"+;
"IFNULL(contrib.nit, ' ') AS NIT,IFNULL(contrib.propieta, ' ') AS PROPIETARIO,IFNULL(contrib.tiporegime, ' ') AS REGIMEN,"+;
"IFNULL(impretef.ANOGRAVA,' ') AS VIGENCIA,IFNULL(impretef.FORMULARIO,' ') AS FORMULARIO,"+;
"IFNULL(impretef.INGREBRU,0) AS INGRESOSBRUTO,IFNULL(impretef.IND_COM_13,0) AS INDUSTRIA,"+;
"IFNULL(impretef.AVISO_14,0) AS AVISO,IFNULL(impretef.ITEM_20,0) AS BOMBERO,IFNULL(impretef.APAGAR_21,0) AS TOTAL_A_PAGAR,"+;
"impretef.ENE AS ENERO,impretef.FEB AS FEB,impretef.MAR AS MAR,impretef.ABR AS ABR,impretef.MAY AS MAY,"+;
"impretef.JUN AS JUNIO,impretef.JUL AS JULIO,impretef.AGO AS AGOSTO,impretef.SEP AS SEPTIMBRE,impretef.OCT AS OCTUBRE,"+;
"impretef.NOV AS NOVIEMBRE,impretef.DIC AS DICIEMBRE,"+;
"impretef.ANUAL AS ANUAL,"+;
"IFNULL(pagos.RECIBOS,0) AS RECIBOS,IFNULL(pagos.FECHA,' / / ') AS FECHAMOVI,IFNULL(SUM(pagos.INDUSTRIA),0) AS INDUSTRIA,"+;
"IFNULL(SUM(pagos.AVISOS),0) AS AVISO,IFNULL(SUM(pagos.BOMBERO),0) AS BOMBERO,"+;
"IFNULL(SUM(pagos.SANCIONES),0) AS SANCIONES,IFNULL(SUM(pagos.ITEM_17),0) AS SANCION_EXTEMPOREANIDAD,"+;
"IFNULL(SUM(pagos.MORA),0) AS MORA,IFNULL(SUM(pagos.MASANTICI),0) AS MAS_ANTICIPO,IFNULL(SUM(pagos.MENOSANTI),0) AS MENOS_ANTICIPO,"+;
"IFNULL(SUM(pagos.AUTORETEN),0) AS AUTORETENCION, IFNULL(SUM(pagos.retencionica),0) AS RETENCION_TITULO_ICA,"+;
"IFNULL(SUM(pagos.INDUSTRIA),0)+IFNULL(SUM(pagos.AVISOS),0)+ IFNULL(SUM(pagos.BOMBERO),0)+IFNULL(SUM(pagos.MORA),0) AS TOTALPAGADO "+;
"FROM contrib LEFT JOIN impretef ON contrib.codigo = impretef.codigo "+;
"LEFT JOIN pagos ON impretef.codigo=pagos.codigo AND impretef.ANOGRAVA = pagos.VIGENCIA AND impretef.FORMULARIO = pagos.FORMULARIO "+;
"WHERE "+;
"contrib.codigo=impretef.codigo GROUP BY impretef.codigo,impretef.anograva,impretef.formulario ORDER BY contrib.codigo,impretef.anograva"
IF !empty( hRes := oo:Query( cSql ) )
? '<br><b>Total Select: </b>', oo:Count( hRes )
aRows := oo:FetchAll( hRes, .t. )
endif
DEFINE WEB oWeb TITLE 'Basic Browse' TABLES INIT
DEFINE FORM o
HTML o INLINE '<h3>Basic Browse</h3><hr>'
INIT FORM o
DEFINE BROWSE oBrw ID 'ringo' HEIGHT 400 OF o
ADD oCol TO oBrw ID 'CODIGO' HEADER 'Codigo'
ADD oCol TO oBrw ID 'RAZON' HEADER 'Razon Social'
ADD oCol TO oBrw ID 'DIRECCION' HEADER 'Direccion'
ADD oCol TO oBrw ID 'TOTAL_A_PAGAR' HEADER 'Total a Pagar'
ADD oCol TO oBrw ID 'TOTALPAGADO' HEADER 'Total Pagado'
INIT BROWSE oBrw DATA aRows
END FORM o
retu nil
Gracias por la atención prestada