Also, take a look at this ancient document that used to be the standard answer to people asking the same question as yours: http://ibobjects.com/docs/ti_AuditableSeries.ZIP
HTH,
Set
2015-12-22 20:26 GMT+01:00 Ann Harrison aharrison@ibphoenix.com [firebird-support] <firebird-support@yahoogroups.com>:
On Tue, Dec 22, 2015 at 9:40 AM, Luigi Siciliano luigisic@tiscalinet.it [firebird-support] <firebird-support@yahoogroups.com> wrote:
I must assign a serial number, without hole, in a column of a fiscal
document. I must assign the number only when I know if the document is complete
and I think the right moment is on a Before Insert Trigger for the table.Yes that's a good place, but you've got to be very careful. Generators/Sequences won'twork because they're deliberately non-transactional. Once you take one its gone and ifyour operation fails, you'll have a hole.
Is right or the insertion can fail? If not right, when I must assign the
number to be sure of not have a hole in numeration?One way to get numbers without holes is to create a table with one field that containsthe seed for your numbers. In your before insert trigger update that field adding one to it,then read to get the new value. Unfortunately, if someone else has inserted a recordconcurrently, your transaction will wait then get an error and you'll need to re-run thewhole thing.Check the FAQ's at FirebirdSQL.org for other ways of handling this problem.Good luck,Ann
__._,_.___
Posted by: =?UTF-8?Q?Svein_Erling_Tysv=C3=A6r?= <setysvar@gmail.com>
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu. Try FAQ and other links from the left-side menu there.
Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu. Try FAQ and other links from the left-side menu there.
Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.
__,_._,___
No comments:
Post a Comment