You are not logged in.
Hi,
I'm about making an invoice system and I've the invoice number composed by the date and an increment, my idea is to retrieve the new ID value and compose the invoice number. Is it possible ?
Thnx,
Offline
I believe before adding a TSQLrecord, you cannot get the ID, and this how sqlite works.
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Is it not possible to retrieve the MAX id value from table so add 1?
Offline
Imagine the record with the highest id has been deleted. Can you tell right away what the next ID will be?
It's an implementation detail and you should never rely on that.
Offline
@A.B : on the client side or server side ?
@edwinsn : Yes wat I want is before adding a TSQLRecord.
Offline
Imagine the record with the highest id has been deleted. Can you tell right away what the next ID will be?
It's an implementation detail and you should never rely on that.
You are right.
I think you should add a black record retrieve the id then update it with real data. It's not a good way but I think the only way.
Last edited by array81 (2014-07-24 13:07:44)
Offline
Use a calculated field.
I mean, store the id and the date in 2 fields.
Then compute the invoice number by concatenating the 2.
So you do not need to store the invoice number as such.
Then you can extract the id from the invoice number.
No need to do something complicated.
Online
Ok I understand, thx to all.
Offline