PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD] Limits on Query execution with MySql
[WD] Limits on Query execution with MySql
Iniciado por guest, 20,sep. 2016 10:54 - 6 respuestas
Publicado el 20,septiembre 2016 - 10:54
Hello to all

I'm trying, without any luck to run this query
sSql is string dsMyQuery is data source bRes is boolean bData is boolean sSql="SELECT r.data, G.Descrizione, SUM(r.importo_prestazione) AS tot_imp_prescr, COUNT(*) AS tot_prescr, " sSql+="(SELECT COUNT(*) FROM registro LEFT JOIN PRESTAZIONI ON REGISTRO.TIPO_PRESTAZIONE=PRESTAZIONI.ID " sSql+="WHERE REGISTRO.TIPO_PRESTAZIONE = 1 AND REGISTRO.data = R.DATA AND R.ID_GMT=REGISTRO.ID_GMT) FROM REGISTRO AS r " sSql+=" LEFT JOIN guardie G ON R.id_gmt=g.id " sSql+="LEFT JOIN prestazioni AS P ON R.tipo_prestazione = p.ID " sSql+=" GROUP BY r.data DESC, G.descrizione ORDER BY r.data DESC" bRes=HExecuteSQLQuery(dsMyQuery,hQueryWithoutCorrection,sSql)
the result of "bRes" is always False !!
Trying copying/pasting the query to a client (SqlYOG), the query is executed correctly.

Do am i missing something? Wrong parameters? HF query execution limits??

Tips and tricks are very appreciated.

Thanks in advance
Gianni
Publicado el 20,septiembre 2016 - 16:32
Hi Gianni,

"...the result of "bRes" is always False !!.."

ok... but what is the error message?

Best regards
Publicado el 20,septiembre 2016 - 16:51
Hello Fabrice

No error messages. The query is not returning data, but only if i build the string containing the query as i post before.
So, i have resolved the trouble applying another way: using a query editor, copying and pasting the whole query string and executing it, the query returns all the records.

I don't know why i can't use a query with multiple SELECT's directly as i posted in origin.

This is the complete query saved as QRY_Global in my project.
SELECT R.data,G.descrizione AS PuntoGuardia,SUM(R.importo_prestazione) AS tot_impo_prescr, COUNT(*) AS tot_prescr, (SELECT COUNT(*) FROM registro LEFT JOIN prestazioni ON registro.tipo_prestazione = prestazioni.id WHERE registro.tipo_prestazione = 1 AND registro.data = r.data AND R.id_gmt = registro.id_gmt) VISIT_AMB, (SELECT COUNT(*) FROM registro LEFT JOIN prestazioni ON registro.tipo_prestazione = prestazioni.id WHERE registro.tipo_prestazione = 2 AND registro.data = r.data AND R.id_gmt = registro.id_gmt) VISIT_DOC, (SELECT COUNT(*) FROM registro LEFT JOIN prestazioni ON registro.tipo_prestazione = prestazioni.id WHERE registro.tipo_prestazione = 3 AND registro.data = r.data AND R.id_gmt = registro.id_gmt) RIP_PRESCR_FARM, (SELECT COUNT(*) FROM registro LEFT JOIN prestazioni ON registro.tipo_prestazione = prestazioni.id WHERE registro.tipo_prestazione = 4 AND registro.data = r.data AND R.id_gmt = registro.id_gmt) RICH_ACCERT_DIAGN_O_RIC, (SELECT COUNT(*) FROM registro LEFT JOIN prestazioni ON registro.tipo_prestazione = prestazioni.id WHERE registro.tipo_prestazione IN(5,7) AND registro.data = r.data AND R.id_gmt = registro.id_gmt) varie, (SELECT COUNT(*) FROM registro LEFT JOIN prestazioni ON registro.tipo_prestazione = prestazioni.id WHERE registro.tipo_prestazione = 6 AND registro.data = r.data AND R.id_gmt = registro.id_gmt) INR, (SELECT COUNT(*) FROM registro LEFT JOIN prestazioni ON registro.tipo_prestazione = prestazioni.id WHERE registro.tipo_prestazione = 8 AND registro.data = r.data AND R.id_gmt = registro.id_gmt) TERAP_INIETTIVA, (SELECT COUNT(*) FROM registro LEFT JOIN prestazioni ON registro.tipo_prestazione = prestazioni.id WHERE registro.tipo_prestazione = 9 AND registro.data = r.data AND R.id_gmt = registro.id_gmt) MISUR_PRESSIONE_ART, (SELECT COUNT(*) FROM registro LEFT JOIN prestazioni ON registro.tipo_prestazione = prestazioni.id WHERE registro.tipo_prestazione = 10 AND registro.data = r.data AND R.id_gmt = registro.id_gmt) VIS_BREVE, (SELECT COUNT(*) FROM registro LEFT JOIN prestazioni ON registro.tipo_prestazione = prestazioni.id WHERE registro.tipo_prestazione = 11 AND registro.data = r.data AND R.id_gmt = registro.id_gmt) VIS_CONTROLLO FROM registro AS R LEFT JOIN id_user I ON R.id_medico = I.User_ID LEFT JOIN guardie G ON R.id_gmt = G.id LEFT JOIN prestazioni P ON R.tipo_prestazione = P.id GROUP BY R.data, G.descrizione ORDER BY r.data DESC
Gulp!!!

Regards :)

Gianni
Publicado el 20,septiembre 2016 - 17:24
Hi Gianni

if the hexecutequery retuns FALSE, as you stated, then there IS AN ERROR MESSAGE.

Your code is just not displaying it.

So do an info(herrorinfo(xxx)) when the result is false and tell us the error message

ANd if you are not doing that each time in your code, it's time to add it everywhere

Best regards
Publicado el 20,septiembre 2016 - 17:29
Hi Fabrice

Thanks for the info..
I will try and i will tell your the result.

Thanks again

Gianni
Publicado el 21,septiembre 2016 - 19:44
Hi

Tip on using mysql. use HeidiSQl . This is a free tool and it rocks. Windev works great with this tool.

regards

allard
Publicado el 22,septiembre 2016 - 08:39
Ciao Gianni,

la funzione HExecuteSQLQuery con il parametro hQueryWithoutCorrection vuole sempre IL NOME DELLA CONNESSIONE come secondo parametro (cioè tra il data source e la costante hQueryWithoutCorrection).

Inoltre ti consiglio sempre di usare un Error(HErrorinfo()) dopo un risultato negativo di HExecuteQuery o HExecuteSQLQuery.

Saluti
Dann