Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
6
Erster Beitrag:
vor 5 Jahren
Letzter Beitrag:
vor 5 Jahren
Beteiligte Autoren:
Piet van Zanten, Mujahid, Jose Antonio Garrido, Peter Holemans

[WD14] Other coding solution

Startbeitrag von Mujahid am 14.08.2013 07:45

Hello All,

Is there any other method for coding based on below example coding:


///////////////////////////////////////////////////////////////////////// Invoice Not Complete

QRY_InvoiceCOGS_NotComplete.pcUnitCost = 0

IF NOT HExecuteQuery(QRY_InvoiceCOGS_NotComplete) THEN
Error("Query initialization error"+CR+HErrorInfo())
RETURN
END

HReadFirst(QRY_InvoiceCOGS_NotComplete)
WHILE NOT HOut()

nRow2 is int = 0
nRow2 = TableSeek(TABLE_COGS_1st.COL_usID,QRY_InvoiceCOGS_NotComplete.usInvoiceID)
IF nRow2 =-1 THEN

TableAddLine(TABLE_COGS_1st,QRY_InvoiceCOGS_NotComplete.usInvoiceCOGSID...)
END
HReadNext(QRY_InvoiceCOGS_NotComplete)
END

HCancelDeclaration(QRY_InvoiceCOGS_NotComplete)



Using this coding, the operation is quite slow. It takes 5 minutes and above to finish the operation.
If there other coding option that can make the operation more fast?

Thanks a lot.

Regards,
Mujahid

Antworten:

Hi Mujahid,

Not sure if it is faster but find it more readable for sure...


QRY_InvoiceCOGS_NotComplete.pcUnitCost = 0
IF HExecuteQuery(QRY_InvoiceCOGS_NotComplete) THEN
FOR ALL QRY_InvoiceCOGS_NotComplete
IF TableSeek(TABLE_COGS_1st.COL_usID,QRY_InvoiceCOGS_NotComplete.usInvoiceID) > 0 THEN
TableAddLine(TABLE_COGS_1st,QRY_InvoiceCOGS_NotComplete.usInvoiceCOGSID...)
END
END
hFreeQuery(QRY_InvoiceCOGS_NotComplete)
ELSE
//Error Handling here using hErrorInfo(hErrMessage) to provide details on the execution issue
END


Cheers,

Peter H.

von Peter Holemans - am 14.08.2013 08:08
Hi Mujahid,

Not sure if this will gain speed in Windev, but you can try storing the InvoiceIDs in an array and use ArraySeek.

//Fill the array after the table is filled or updated
ArrayDeleteAll(ar_ID)
FOR ALL TABLE_COGS_1st
ArrayAdd(ar_ID,COL_usID)
END
//
IF HExecuteQuery(QRY_InvoiceCOGS_NotComplete) THEN
FOR ALL QRY_InvoiceCOGS_NotComplete
IF arraySeek(ar_ID, asLinearFirst, QRY_InvoiceCOGS_NotComplete.usInvoiceID)=-1 THEN
TableAddLine(TABLE_COGS_1st,QRY_InvoiceCOGS_NotComplete.usInvoiceCOGSID...)
END
END
hFreeQuery(QRY_InvoiceCOGS_NotComplete)
ELSE
//Error Handling here using hErrorInfo(hErrMessage) to provide details on the execution issue
END

Slightly faster may be an array of structures that holds both rownumber and ID and sort the array, then do a binary search.

Regards,
Piet

von Piet van Zanten - am 14.08.2013 08:26
Hello,

Peter H, I just try your coding but still take times to settle it.

Piet, actually im not familiar using array. But i try using below coding :


ar_ID is array of strings

QRY_InvoiceCOGS_NotComplete.pcUnitCost = 0
IF HExecuteQuery(QRY_InvoiceCOGS_NotComplete) THEN
FOR ALL QRY_InvoiceCOGS_NotComplete
IF ArraySeek(ar_ID, asLinearFirst, QRY_InvoiceCOGS_NotComplete.usInvoiceID)=-1 THEN
ArrayAddLine(ar_ID,QRY_InvoiceCOGS_NotComplete.usInvoiceID)
TableAddLine(TABLE_COGS_1st,QRY_InvoiceCOGS_NotComplete.usInvoiceCOGSID...)

END
END
HCancelDeclaration(QRY_InvoiceCOGS_NotComplete)
ELSE
//Error Handling here using hErrorInfo(hErrMessage) to provide details on the execution issue
END


The result also take times to settle the operation.
Any advise or recommendation?

Thanks a lot.

Regards,
Mujahid

von Mujahid - am 14.08.2013 11:20
Hi.

QRY_InvoiceCOGS_NotComplete.pcUnitCost = 0
HExecuteQuery(QRY_InvoiceCOGS_NotComplete)

1.How many time takes the query to run? It should be less than one second.
2.And how many records are returned by the query? It should be less than 100, since they are the lines of the Invoice.

It's just to know in which part is the time being spent.

Regards,
José Antonio.

von Jose Antonio Garrido - am 14.08.2013 12:16
Hi Mujahid,

Use the profiler.
At the start of the code insert ProfilerStart(), at the end ProfilerEnd()
Then you can see which part of your code is the most time consuming.

Regards,
Piet

von Piet van Zanten - am 14.08.2013 16:04
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.