Hi Thomas,

Sounds like a much cleverer solution. I'm not sure what you mean by an
associative hash or how I would create it and test the serial numbers
against it. I know a little about using hash functions in cryptography
and signing but only in very basic terms.

I don't run both queries for every label, it depends on which part is
being printed. There are a couple of dozen different parts that can be
produced by the app.

Thanks,
Dave.

Dave Murray
Delphi-En Moderator
Glasgow, UK
[EMAIL PROTECTED]


--- In [email protected], Thomas Hruska <[EMAIL PROTECTED]> wrote:
>
> 
> I see your problem.  You take a linear logical approach to reach a 
> working solution.  It won't matter what DB you use if you use such
> and approach - performance will suck.  What you should do is 
> generate a list of 1000 serial numbers and store them in an array 
> AND associative hash. 
>   You can make sure the list is unique by checking each new serial 
> number generated against those in the associative hash.  Then, run 
> the first SQL query.  For each row in the query, check the 
> associative hash to see if the serial number already exists.  If it 
> does, locate it in the array and flag it as not being unique.  
> Repeat for the second query.
> 
> Once the two queries have been processed, the array contains a 
> unique set of serial numbers to both itself and the database.  Run a 
> batch insert to add the serial numbers to the 'LOG' table __BUT__ 
> flag them as having not been used.  This allows you to have two 
> programs:  One that generates valid serial numbers and one that 
> prints the labels.
> 
> If you use the two program approach, the program that prints the 
> labels simply has to run the appropriate SQL query for _unused_ 
> serial numbers, run an UPDATE query to flag it as used, and then 
> print the serial number.
> 
> One way to further improve performance with this approach would be 
> to remove the 'order by' and introduce a surrogate primary key using 
> an 'autonumber'.  A 32-bit integer outperforms ASCII string 
> comparisons any day.
> 
> --
> Thomas Hruska
> CubicleSoft President
> Ph: 517-803-4197
> 
> Safe C++ Design Principles (First Edition)
> Learn how to write memory leak-free, secure,
> portable, and user-friendly software.
> 
> Learn more and view a sample chapter:
> http://www.CubicleSoft.com/SafeCPPDesign/
>






-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to