Article View: borland.public.cppbuilder.database.ado
Article #5216Re: Clarification on AutoInc fields
From: Formentz
Date: Fri, 06 Jul 2001 07:58
Date: Fri, 06 Jul 2001 07:58
37 lines
2378 bytes
2378 bytes
Hi Umberto,
here there is the same problem, I'll have to lock the table before using the
query you wrote, because if there are 2 readings before the row has been
inserted, 2 new records will have the same id, and then one will be rejected
by the index.
Another thing, I don't know how to translate 'fattura' in english, but you
are italian (aren't you? :-), and you surely know what I mean.
This fattura must have consequent numbers and consequent dates, so I can't
have a fattura with previous number but later date, and this should be the
case if a previous number is picked with a later date.
Ciao
Formentz
"Umberto Uderzo" <umberto@uderzo.it> ha scritto nel messaggio
news:3b44f7c5_2@dnews...
> Hello Francesco,
>
> Ok, if your need is to obtain contiguous ids your way is sure right.
> But what if the table is used by many users and the row creation process
> involves much time?
> You gain a lot of waiting locks...
> If you can have temporary holes in your id sequence you can use the
> following query:
>
> SELECT MIN(t1.id)+1
> FROM <table_name> t1
> WHERE NOT EXISTS
> SELECT t2.id
> FROM <table_name> t2
> WHERE t2.id = t1.id + 1
>
> So if there are holes in your id sequence, the next query will fill the
> first hole of the sequence.
>
> Ciao... Umberto Uderzo
>
Technical Details
Message-ID:
<3b456e91$1_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.he.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3b3b532b$1_2@dnews> <3B3BD2D2.5F446F35@temporaldoorway.com> <3b3c3ad2_1@dnews> <3b3c7c38_1@dnews> <3b40f10e_2@dnews> <3b441a9c$2_2@dnews> <3b44f7c5_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,2eab2f6830ef7732 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-07-06 01:09:07 PST From: "Formentz" <francesco@leotron.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3b3b532b$1_2@dnews> <3B3BD2D2.5F446F35@temporaldoorway.com> <3b3c3ad2_1@dnews> <3b3c7c38_1@dnews> <3b40f10e_2@dnews> <3b441a9c$2_2@dnews> <3b44f7c5_2@dnews> Subject: Re: Clarification on AutoInc fields Date: Fri, 6 Jul 2001 09:58:21 +0200 Lines: 40 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 62.122.28.24 Message-ID: <3b456e91$1_2@dnews> X-Trace: dnews 994406033 62.122.28.24 (6 Jul 2001 00:53:53 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.he.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews