By the way, if you do everything in sql, you should use "SELECT
scope_identity()" instead of "SELECT @@identity". The reason being that if
your insert calls a trigger on that table that in turns inserts a row in
another table, scope_identity() would return the id of the new row you
explicitly inser
Less code, and database agnostic. Behind the scenes it probably does the
same thing.
On Wed, Jan 27, 2016 at 12:01 PM, Mike K wrote:
> Whats the advantage of returning result.getPrefix().generatedkey rather
> than using the @@identity function of the database?
>
> Is it just to make it databas
Whats the advantage of returning result.getPrefix().generatedkey rather
than using the @@identity function of the database?
Is it just to make it database agnostic? or is there another reason for
it?
Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Web
Thanks. Looks like the easiest way to do this.
Brian
From: "Paul Kukiel"
Sent: Wednesday, 27 January 2016 10:55 AM
To: cfaussie@googlegroups.com
Subject: Re: [cfaussie] SQL identity issue
100% reliable.
On Wed, Jan 27, 201
rts.
>
> Does anyone know how reliable the GENERATEKEY function is.
>
> Brian
>
>
>
> --
> *From*: "Paul Kukiel"
> *Sent*: Wednesday, 27 January 2016 10:29 AM
> *To*: cfaussie@googlegroups.com
> *Subject*: Re: [cfaussie] SQ
Brian
From: "Paul Kukiel"
Sent: Wednesday, 27 January 2016 10:29 AM
To: cfaussie@googlegroups.com
Subject: Re: [cfaussie] SQL identity issue
Same as Mikes but using the inbuilt functions and avoiding @@identity
INSERT INTO MyTable (col1)
Same as Mikes but using the inbuilt functions and avoiding @@identity
INSERT INTO MyTable (col1)
VALUES ('col1')
Inserted ID is: #myResult["GENERATEDKEY"]#
On Wed, Jan 27, 2016 at 11:06 AM, Mark King wrote:
> Hi Brian.
>
>
>
> Well first of all if you are using SQL Server try this to get
You could also generate a hash of their name and address as the seed,
assuming there isn't 2 customers with the same name and address (and you
already have this data at this point)
On 27 Jan 2016 7:05 a.m., "Mike K" wrote:
> Can you combine that random number with something sequential like maybe
Hi Brian.
Well first of all if you are using SQL Server try this to get the new ID in the
same transaction rather than doing another query;
SET NOCOUNT ON
INSERT INTO orders
(
** Your order fields **
)
VALUES
Can you combine that random number with something sequential like maybe an
index field? that way you'll give the customer a random order number but
still be able to keep uniqueness. You could generate the random
number, then append the sequential index to it making a larger integer.
Or you
Two issues there, really, it seems, Brian.
1) When you need more truly random numbers, you should call the Randomize
function first, and in it you can provide both a seed and an alternative
randomization algorithm. See the CF docs, such as (for cf9, which sadly comes
up first in google search r
11 matches
Mail list logo