--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/947f4824-e06d-4d4e-aa9c-5ff689cb99f0n%40googlegroups.com.
Hi!
I think AScan does a simple sequential search, so it can't be as fast as index search. Perhaps a replacement for AScan could be made that uses a memory table and a seek search?
Regards, NB
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/CADPHLr9RmwyV7Gca1zGtUyudF0JCNuM%3DW04EvP2VvEX7Errwsw%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/008601dcb980%24ecd55a70%24c6800f50%24%40wings.rs.
If anyone remembers the CA Visual Objects project... It had a very nice object-oriented approach to working with the database. It looks like this:
oDb := DBServer ("Test")
oDb:SetIndex ("Test_ID")
WHILE ! oDb:Eof()
IF oDb:Id == 0
oDb:Id := RecNo()
oDb:Name := "None"
END IF
oDb:Skip()
END DO
I believe this code is clear to everyone :) The really good thing is that almost identical code could also work with SQL Server. Only the initialization was a little different:
oDb := SQLSelect ("SELECT * FROM Test ORDER BY Id")
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/CADPHLr-OJcJniJq7XKDmy%3D7xfdW_GxBGP4JoYLa9WXG0co32PQ%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/00e401dcba52%2417cc93c0%244765bb40%24%40wings.rs.
Thank you, Francesco Perillo.
You're right about member access being slower.
I tried another approach as shown below:
FOR EACH oHdr IN aHeaders
? "Header : " + oHdr:cHeaderKey + " Customer: " + oHdr:cCustName
FOR EACH oDtl IN oHdr:aDetails
? " Detail : " + oDtl:cDetailKey + " Amt: " + hb_ntos( oDtl:nAmount )
FOR EACH oSub IN oDtl:aSubs
? " Sub : " + oSub:cSubKey + " Sub amount: " + hb_ntos( oSub:nSubAmt )
nGrandTotal += oSub:nSubAmt
NEXT
NEXT
NEXT
This approach is faster than the previous one — it now takes around 3–4 minutes to process the same data. However, I would like to optimize it further if possible.
This could be an alternative to the code + key approach.
The relationship between Header, Detail, and Sub is one-to-many, so I have to loop through all records to calculate the grand total amount.
I also tried using a hash, but it turned out to be slower than the class-based approach.
Regards, Atul
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/6c2f320d-81eb-4a87-876f-c96e2a65f7ebn%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/harbour-users/97a698f3-ae3b-4631-9215-adff74996391n%40googlegroups.com.
That's a great point, Francesco.
The reason is that I am refactoring my code following Hexagonal Architecture, where I want to clearly separate the Model, UI, Core, and Adapter layers.
By keeping these layers separate, I can easily replace the Adapter in the future with any other data source or technology, such as SQL, without touching the business logic or the presentation layer.
Thanks, Atul