You could also use the small table (MAX_ID_orgs below) method Microsoft
recommended for SQL6 or so (forget the Article number):
<CFQUERY NAME="AddRow" DATASOURCE="" PASSWORD="" USERNAME="">
BEGIN TRANSACTION
UPDATE MAX_ID_orgs SET MAX_ID_org = MAX_ID_org + 1
DECLARE @MAX INT
SELECT @MAX = MAX_ID_org FROM MAX_ID_orgs
INSERT INTO Orgs
(ID, Class, Contact, org_name, org_add, City, State, Zip, Telephone, Credit)
VALUES
(@MAX, #Session.ClassNumber#, '#Form.Contact#', '#Form.org_name#',
'#Form.org_add#', '#Form.City#', 'CA', '#Form.Zip#', '#Form.Telephone#',
'#Session.Credit#')
COMMIT TRANSACTION
</CFQUERY>
At 09:37 AM 12/7/00 +1300, you wrote:
>The most reliable way as far as I can see is to select the max id using the
>exact criteria. I mean, come on, how likely is a collision?
>
>David Cummins
>
>Rob Keniger wrote:
> >
> > on 6/12/00 10:24 PM, DeVoil, Nick at [EMAIL PROTECTED] wrote:
> >
> > > There is no way of doing this with MySQL AFAIK,
> > > not via ODBC anyway.
> > >
> > > Maybe instead of an autonumber you could generate
> > > a quasi-unique ID using some other info - timestamp,
> > > user name, whatever.
> >
> > I have used this method before, using CreateUUID(). Pretty hefty for an ID
> > but it works.
> >
> > I have also done a SELECT back on the table using the exact criteria I have
> > just INSERTed. Obviously this will not work in all cases.
> >
> > Unfortunately the only alternative is to lock tables which is bad bad bad.
> >
> > --
> >
> > Rob Keniger
> >
> > big bang solutions
> >
> > <mailto:[EMAIL PROTECTED]>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists