This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, I'm using for each entities the KeyTable method for Identity Generation due to their DB portability. But now, I would like to use another entity property than Id to keep a index of creation. For example, in my Invoice Entity, I 'll add a property InvoiceIndex which should be equal to 1 for the first created invoice, 2 for the second, ..., n for the nth and this independantly to the Identity column ID.
Thanks for your help. Jonathan. |
|
|
We don't provide a built-in way of doing this. The best approach would depend on requirements (e.g. strictness, concurrency/number of processes), usage patterns (e.g. bulk insert vs. interactive) and the type of database (e.g. does it have triggers, does it have sequences). In any event it would have to be external to LightSpeed. |
|
|
Just to add to Ivan's comment here and give on application specific example - I have built a basic invoicing system that required an incrementing invoice number. Obviously the PK wouldn't do in this situation so I implemented something akin to the KeyTable pattern, but called "InvoiceNumber" which was a table with a single value stored in it for NextInvoiceNumber. As the code for creating an invoice all went through a single point, it was easy to add a lock and then select back the InvoiceNumber, increment it and assign that InvoiceNumber to the invoice entity I had. Invoice number was just an integer field on an Invoice entity - not at all related to the PK. This approach worked as I could easily get a global lock and logically it only made sense to apply an invoice number at one single point. As Ivan stated, your application will dictate how you achieve the desired result, however this is just one example that might help guide you :-) I hope that helps, John-Daniel |
|