Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
2
Erster Beitrag:
vor 1 Jahr, 2 Monaten
Letzter Beitrag:
vor 1 Jahr, 2 Monaten
Beteiligte Autoren:
Gianni Spano

[WD] MySql Query returns different result

Startbeitrag von Gianni Spano am 20.02.2017 20:08

Hello to all

I have a strange situation during different execution of a query:

The query is:

sSql="SELECT mag.codice, mag.descrizione, MONTH(mov.data_mov) AS mese, SUM(mov.qta) AS qtaAcq "
sSql+=" FROM movimenti as mov INNER JOIN magazzino AS mag ON mov.codice_articolo=mag.codice "
sSql+=" WHERE mov.causale BETWEEN 200 AND 202 "
sSql+=" AND mov.anno_mov="+nAnno
sSql+=" AND mag.fornitore_abituale="+nFornitore
sSql+=" GROUP BY mag.codice, MONTH(mov.data_mov)"




bRes=HExecuteSQLQuery(dsMyQueryAcq,MyConnection1,hQueryWithoutCorrection,sSql)


IF bRes=False THEN
Info ("Errore durante l'elaborazione sul database"+CR+CR+HErrorInfo())
RETURN
ELSE
bDati=HReadFirst (dsMyQueryAcq)
IF bDati THEN
WHILE NOT HOut ()
IF dsMyQueryAcq.codice "" THEN
// if dsMyQueryAcq.codice="919947" THEN
// info ("stop!")
// END
IF sUltCodice dsMyQueryAcq.codice THEN
IF nRiga > 0 THEN
FOR j=1 TO 12
nTotale+={"Table_acquisti.col_mese"+j}[nRiga]
END
TABLE_Acquisti.COL_Totali[nRiga]=nTotale
END
TableAdd (TABLE_Acquisti,dsMyQueryAcq.codice+TAB+dsMyQueryAcq.descrizione)
nTrovati+=1
nRiga=TABLE_Acquisti..Occurrence
sUltCodice=dsMyQueryAcq.codice
nTotale=0
nMese=dsMyQueryAcq.mese
{"table_acquisti.col_mese"+nMese}[nRiga]=dsMyQueryAcq.qtaAcq
ELSE
nMese=dsMyQueryAcq.mese
{"table_acquisti.col_mese"+nMese}[nRiga]=dsMyQueryAcq.qtaAcq
END
END
HReadNext ()
END
END
END


What i'm trying to obtain is a list of products and for each month with a value, it
add the quantity bought/sold in a cell.

When the query is executed the 1st time, the result is correct.
Using the same parameters and trying to execute the query a second time, the result is
totally different and without errors or other issues.
Pratically in the table are shown only the code and product name, despite using the debug i see the correct value in the variable, but it is not shown on the table...Why??

Do i missing something??

Thanks in advance
Gianni


This is the table used:
[attachment 2283 scheda.png]

Antworten:

Hello to all

SOLVED partially or i have discovered the reason.

In the portion of code above, there isn't an line with :

tablesort (table_acquisti, "+col_descrizione") to sort the list in product name order.

If i uncomment this line, the result is correct every time i execute the query,
but if i insert this command, the 2nd (and other time) i execute the query the result
is incorrect..

Why?? Any idea?

Gianni

von Gianni Spano - am 20.02.2017 20:19
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.