FWH MySQL/MariaDB Rowset / cQuery
Posted: Sat Apr 07, 2018 9:56 am
Estimados, no logro encontrar cQuery que usan TMysql y TDolphin de manera similar en Fwmaria, para poder consultar el query que estoy enviando o para enviar uno nuevo, si bien el Requery() es su equivalente pero funciona bajo parametros del Where, Order by pero no dentro de las columnas del Select por ejemplo:
EN TMYSQL
cPre:=IF(EMPTY(::vGet:cCodPre),"A","B")+".precio"
cUnd:=IF(EMPTY(::vGet:cCodPre),"A","B")+".undmed"
::cSql:="SELECT A.codigo,A.descripc,IF(A.moneda='S','S/','US$') AS nommoneda,"+cPre+" AS precvta,"+cUnd+",IF("+cUnd+"='','',E.nombre) AS desundmed,"+;
"A.undpre,IF(A.undpre='','',F.nombre) AS desundpre,IF(A.inafecto=0,IF(A.masigv=1,'MAS IGV ','INCL.IGV '),IF(A.inafecto=1,'EXONERADO ','INAFECTO ')) AS nomigv,"+;
"A.tipexis,C.nombre AS nomtipexis,A.tipprod,D.nombre AS nomtipprod,A.anulado "+;
"FROM maeartic AS A LEFT JOIN maelispre AS B ON B.codlispre='"+::vGet:cCodPre+"' AND B.codart=A.codigo "+;
"LEFT JOIN maetabla AS C ON C.codigo=CONCAT('01',A.tipexis) LEFT JOIN maetabla AS D ON D.codigo=CONCAT('02',A.tipprod) "+;
"LEFT JOIN maetabla AS E ON E.codigo=CONCAT('06',"+cUnd+") LEFT JOIN maetabla AS F ON F.codigo=CONCAT('05',A.undpre) "
:oSql:cQuery:=::cSql
::oSql:REFRESH()
Obteniendo mi consulta si inconveniente
en FWmaria lo hago de la siguiente manera y no logro pasar los parametros a las columnas de la consulta, solamente al where y order by,
::cSql:="SELECT A.codigo,A.descripc,IF(A.moneda='S','S/','US$') AS nommoneda,? AS precvta, ? ,IF( ? ='','',E.nombre) AS desundmed,"+;
"A.undpre,IF(A.undpre='','',F.nombre) AS desundpre,IF(A.inafecto=0,IF(A.masigv=1,'MAS IGV ','INCL.IGV '),IF(A.inafecto=1,'EXONERADO ','INAFECTO ')) AS nomigv,"+;
"A.tipexis,C.nombre AS nomtipexis,A.tipprod,D.nombre AS nomtipprod,A.anulado "+;
"FROM maeartic AS A LEFT JOIN maelispre AS B ON B.codlispre= ? AND B.codart=A.codigo "+;
"LEFT JOIN maetabla AS C ON C.codigo=CONCAT('01',A.tipexis) LEFT JOIN maetabla AS D ON D.codigo=CONCAT('02',A.tipprod) "+;
"LEFT JOIN maetabla AS E ON E.codigo=CONCAT('06', ? ) LEFT JOIN maetabla AS F ON F.codigo=CONCAT('05',A.undpre) "
::oSql:=MEMVAR->oConex:RowSet(::cSql+" ? ? ",{ "A.precio","A.undmed","A.undmed","''","A.undmed","WHERE A.codigo IS NOT NULL","ORDER BY A.codigo"})
::oSql:REQUERY( {"B.precio","B.undmed","B.undmed","'0001'","B.undmed","WHERE A.codigo IS NOT NULL","ORDER BY A.codigo"} )
El resultado se muestra con las columnas precvta y desundmed nulos
Por favor espero sus comentarios
FW1705 + BCC7 + MYSQL
EN TMYSQL
cPre:=IF(EMPTY(::vGet:cCodPre),"A","B")+".precio"
cUnd:=IF(EMPTY(::vGet:cCodPre),"A","B")+".undmed"
::cSql:="SELECT A.codigo,A.descripc,IF(A.moneda='S','S/','US$') AS nommoneda,"+cPre+" AS precvta,"+cUnd+",IF("+cUnd+"='','',E.nombre) AS desundmed,"+;
"A.undpre,IF(A.undpre='','',F.nombre) AS desundpre,IF(A.inafecto=0,IF(A.masigv=1,'MAS IGV ','INCL.IGV '),IF(A.inafecto=1,'EXONERADO ','INAFECTO ')) AS nomigv,"+;
"A.tipexis,C.nombre AS nomtipexis,A.tipprod,D.nombre AS nomtipprod,A.anulado "+;
"FROM maeartic AS A LEFT JOIN maelispre AS B ON B.codlispre='"+::vGet:cCodPre+"' AND B.codart=A.codigo "+;
"LEFT JOIN maetabla AS C ON C.codigo=CONCAT('01',A.tipexis) LEFT JOIN maetabla AS D ON D.codigo=CONCAT('02',A.tipprod) "+;
"LEFT JOIN maetabla AS E ON E.codigo=CONCAT('06',"+cUnd+") LEFT JOIN maetabla AS F ON F.codigo=CONCAT('05',A.undpre) "
:oSql:cQuery:=::cSql
::oSql:REFRESH()
Obteniendo mi consulta si inconveniente
en FWmaria lo hago de la siguiente manera y no logro pasar los parametros a las columnas de la consulta, solamente al where y order by,
::cSql:="SELECT A.codigo,A.descripc,IF(A.moneda='S','S/','US$') AS nommoneda,? AS precvta, ? ,IF( ? ='','',E.nombre) AS desundmed,"+;
"A.undpre,IF(A.undpre='','',F.nombre) AS desundpre,IF(A.inafecto=0,IF(A.masigv=1,'MAS IGV ','INCL.IGV '),IF(A.inafecto=1,'EXONERADO ','INAFECTO ')) AS nomigv,"+;
"A.tipexis,C.nombre AS nomtipexis,A.tipprod,D.nombre AS nomtipprod,A.anulado "+;
"FROM maeartic AS A LEFT JOIN maelispre AS B ON B.codlispre= ? AND B.codart=A.codigo "+;
"LEFT JOIN maetabla AS C ON C.codigo=CONCAT('01',A.tipexis) LEFT JOIN maetabla AS D ON D.codigo=CONCAT('02',A.tipprod) "+;
"LEFT JOIN maetabla AS E ON E.codigo=CONCAT('06', ? ) LEFT JOIN maetabla AS F ON F.codigo=CONCAT('05',A.undpre) "
::oSql:=MEMVAR->oConex:RowSet(::cSql+" ? ? ",{ "A.precio","A.undmed","A.undmed","''","A.undmed","WHERE A.codigo IS NOT NULL","ORDER BY A.codigo"})
::oSql:REQUERY( {"B.precio","B.undmed","B.undmed","'0001'","B.undmed","WHERE A.codigo IS NOT NULL","ORDER BY A.codigo"} )
El resultado se muestra con las columnas precvta y desundmed nulos
Por favor espero sus comentarios
FW1705 + BCC7 + MYSQL