AW: MySQL Auto Increment Field

2009-10-01 Thread Gert Franz

Barneyb,

Railo only retrieves the result when you actually use a result attribute in
the query. If you are not using it then it is not slower. On the other hand
the result attribute must already contain the value after the cfquery is
executed. This is due to the fact that when retrieving AutoInc numbers a
different code needs to be executed, containing data that is only available
at query execution time. So even if lazy loading would be superb to have
when you have a result attribute, it is not possible to execute the
necessary code to fill the GENERATEDKEY field of the result struct.

PS: Your business card almost put me into trouble with my GF :-)

Greetings from Switzerland
Gert Franz

Railo Technologies  Professional Open Source
skype: gert.franz   g...@getrailo.com
+41 76 5680 231 www.getrailo.com


-Ursprüngliche Nachricht-
Von: Barney Boisvert [mailto:bboisv...@gmail.com] 
Gesendet: Donnerstag, 1. Oktober 2009 07:36
An: cf-talk
Betreff: Re: MySQL Auto Increment Field


Just out of curiosity Sean, do you know if the value is lazy loaded,
or do you have to pay the cost of retrieving the value on every query
(or at least introspecting to determine whether a value is available)
regardless?  I know you're closest to Railo, but I'm interested in
both (all three?) platforms if you've got the info.

cheers,
barneyb

On Wed, Sep 30, 2009 at 10:19 PM, Sean Corfield seancorfi...@gmail.com
wrote:

 On Tue, Sep 29, 2009 at 12:22 PM, Azadi Saryev az...@sabai-dee.com
wrote:
 if you are on CF8, use RESULT attribute of cfquery tag and then get
 GENERATED_KEY from that result:
 cfquery name=myquery datasource=... result=qResult
 INSERT ...
 /cfquery
 cfset newID = qResult.GENERATED_KEY

 As an aside, the generated key is placed into a different element of
 the result struct for each different database in CF8 (why??!?!) but
 that is fixed in CF9 which also adds GENERATEDKEY for *all* DB types
 so you can write portable code (assuming you stick to standard SQL of
 course and not TSQL - sorry Robert, couldn't resist! :)

 Railo recently implemented this same feature (both adding the various
 DB-specific generated key elements as well as the generic GENERATEDKEY
 element). I don't know whether Open BlueDragon supports this feature
 yet. Anyone?
 --
 Sean A Corfield -- (904) 302-SEAN
 Railo Technologies US -- http://getrailo.com/
 An Architect's View -- http://corfield.org/
-- 
Barney Boisvert
bboisv...@gmail.com
http://www.barneyb.com/



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326792
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: MySQL Auto Increment Field

2009-09-30 Thread Leigh

 The article did mention trouble coming from the database
 itself if ones  insert caused a trigger to be fired.  Then the
 @@identity could return 
 the generated key from what ever the trigger created.

Yes, and it does. Having had that unpleasant experience once, with an older 
application, convinced me to switch to using SCOPE_IDENTITY().  Granted, not 
everyone uses triggers, or ones that involve an identity column on another 
table, but better safe than sorry. 

-Leigh


 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326786
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: MySQL Auto Increment Field

2009-09-30 Thread Sean Corfield

On Tue, Sep 29, 2009 at 12:22 PM, Azadi Saryev az...@sabai-dee.com wrote:
 if you are on CF8, use RESULT attribute of cfquery tag and then get
 GENERATED_KEY from that result:
 cfquery name=myquery datasource=... result=qResult
 INSERT ...
 /cfquery
 cfset newID = qResult.GENERATED_KEY

As an aside, the generated key is placed into a different element of
the result struct for each different database in CF8 (why??!?!) but
that is fixed in CF9 which also adds GENERATEDKEY for *all* DB types
so you can write portable code (assuming you stick to standard SQL of
course and not TSQL - sorry Robert, couldn't resist! :)

Railo recently implemented this same feature (both adding the various
DB-specific generated key elements as well as the generic GENERATEDKEY
element). I don't know whether Open BlueDragon supports this feature
yet. Anyone?
-- 
Sean A Corfield -- (904) 302-SEAN
Railo Technologies US -- http://getrailo.com/
An Architect's View -- http://corfield.org/

If you're not annoying somebody, you're not really alive.
-- Margaret Atwood

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326789
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: MySQL Auto Increment Field

2009-09-30 Thread Barney Boisvert

Just out of curiosity Sean, do you know if the value is lazy loaded,
or do you have to pay the cost of retrieving the value on every query
(or at least introspecting to determine whether a value is available)
regardless?  I know you're closest to Railo, but I'm interested in
both (all three?) platforms if you've got the info.

cheers,
barneyb

On Wed, Sep 30, 2009 at 10:19 PM, Sean Corfield seancorfi...@gmail.com wrote:

 On Tue, Sep 29, 2009 at 12:22 PM, Azadi Saryev az...@sabai-dee.com wrote:
 if you are on CF8, use RESULT attribute of cfquery tag and then get
 GENERATED_KEY from that result:
 cfquery name=myquery datasource=... result=qResult
 INSERT ...
 /cfquery
 cfset newID = qResult.GENERATED_KEY

 As an aside, the generated key is placed into a different element of
 the result struct for each different database in CF8 (why??!?!) but
 that is fixed in CF9 which also adds GENERATEDKEY for *all* DB types
 so you can write portable code (assuming you stick to standard SQL of
 course and not TSQL - sorry Robert, couldn't resist! :)

 Railo recently implemented this same feature (both adding the various
 DB-specific generated key elements as well as the generic GENERATEDKEY
 element). I don't know whether Open BlueDragon supports this feature
 yet. Anyone?
 --
 Sean A Corfield -- (904) 302-SEAN
 Railo Technologies US -- http://getrailo.com/
 An Architect's View -- http://corfield.org/
-- 
Barney Boisvert
bboisv...@gmail.com
http://www.barneyb.com/

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326791
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


MySQL Auto Increment Field

2009-09-29 Thread Agha Mehdi

All,
How do I get the ID value back in CF from MySQL after doing an insert with
auto_inc data type in the table?

Thanks for help

Agha


~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326747
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: MySQL Auto Increment Field

2009-09-29 Thread Azadi Saryev

if you are on CF8, use RESULT attribute of cfquery tag and then get
GENERATED_KEY from that result:
cfquery name=myquery datasource=... result=qResult
INSERT ...
/cfquery
cfset newID = qResult.GENERATED_KEY

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/


On 30/09/2009 03:16, Agha Mehdi wrote:
 All,
 How do I get the ID value back in CF from MySQL after doing an insert with
 auto_inc data type in the table?

 Thanks for help

 Agha


 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326748
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: MySQL Auto Increment Field

2009-09-29 Thread Barney Boisvert

select last_insert_id() as id

http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id

cheers,
barneyb

On Tue, Sep 29, 2009 at 12:16 PM, Agha Mehdi aghaime...@gmail.com wrote:

 All,
 How do I get the ID value back in CF from MySQL after doing an insert with
 auto_inc data type in the table?

 Thanks for help

 Agha


 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326749
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: MySQL Auto Increment Field

2009-09-29 Thread Will Swain

Nice Azadi, I didn't know you could do that.

Will 

-Original Message-
From: Azadi Saryev [mailto:az...@sabai-dee.com] 
Sent: 29 September 2009 20:23
To: cf-talk
Subject: Re: MySQL Auto Increment Field


if you are on CF8, use RESULT attribute of cfquery tag and then get
GENERATED_KEY from that result:
cfquery name=myquery datasource=... result=qResult INSERT ...
/cfquery
cfset newID = qResult.GENERATED_KEY

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/


On 30/09/2009 03:16, Agha Mehdi wrote:
 All,
 How do I get the ID value back in CF from MySQL after doing an insert 
 with auto_inc data type in the table?

 Thanks for help

 Agha


 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326750
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: MySQL Auto Increment Field

2009-09-29 Thread Agha Mehdi

Thanks Azadi and Barney. Which approach is better in performance? I'm  
assuming result.generated_key?

Thanks again for help

Agha

On Sep 29, 2009, at 12:20 PM, Barney Boisvert bboisv...@gmail.com  
wrote:


 select last_insert_id() as id

 http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id

 cheers,
 barneyb

 On Tue, Sep 29, 2009 at 12:16 PM, Agha Mehdi aghaime...@gmail.com  
 wrote:

 All,
 How do I get the ID value back in CF from MySQL after doing an  
 insert with
 auto_inc data type in the table?

 Thanks for help

 Agha




 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326751
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: MySQL Auto Increment Field

2009-09-29 Thread Robert Harrison

You can also do this using SQL. Sure this works with MS SQL, not 100% sure
about mySQL but it's standard SQL, so it should work.


cfquery name=putData datasource=#dsn#
  SET NOCOUNT ON
 INSERT INTO my_table (my_field1, my_field2)
 VALUES ('#trim(value_field1)#', ('#trim(value_field2)#')
  SELECT @@Identity AS newId  
  SET NOCOUNT OFF ;
/cfquery

cfoutputThe Generated ID is: #putData.newId#/cfoutput


Robert B. Harrison
Director of Interactive Services
Austin  Williams
125 Kennedy Drive, Suite 100 
Hauppauge NY 11788
P : 631.231.6600 Ext. 119 
F : 631.434.7022
http://www.austin-williams.com 

Great advertising can't be either/or.  It must be .

Plug in to our blog: AW Unplugged
http://www.austin-williams.com/unplugged



On 30/09/2009 03:16, Agha Mehdi wrote:
 All,
 How do I get the ID value back in CF from MySQL after doing an insert with
 auto_inc data type in the table?

 Thanks for help

 Agha


 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326752
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: MySQL Auto Increment Field

2009-09-29 Thread Dave Watts

 You can also do this using SQL. Sure this works with MS SQL, not 100% sure
 about mySQL but it's standard SQL, so it should work.

 cfquery name=putData datasource=#dsn#
      SET NOCOUNT ON
         INSERT INTO my_table (my_field1, my_field2)
         VALUES ('#trim(value_field1)#', ('#trim(value_field2)#')
      SELECT @@Identity AS newId
      SET NOCOUNT OFF ;
 /cfquery

 cfoutputThe Generated ID is: #putData.newId#/cfoutput

The @@IDENTITY global variable is not standard SQL. It's specific to
T-SQL. So is SET NOCOUNT ON|OFF. Of the four SQL statements you've
listed, one is standard SQL.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326753
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: MySQL Auto Increment Field

2009-09-29 Thread Dave Watts

 Thanks Azadi and Barney. Which approach is better in performance? I'm
 assuming result.generated_key?

I would assume that there wouldn't be a significant performance
difference either way.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326754
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: MySQL Auto Increment Field

2009-09-29 Thread Robert Harrison

Yes. You're correct. My Bad. TSQL. 

That's probably why I should just turn off email when I'm busy on something
else. 


Robert B. Harrison
Director of Interactive Services
Austin  Williams
125 Kennedy Drive, Suite 100 
Hauppauge NY 11788
P : 631.231.6600 Ext. 119 
F : 631.434.7022
http://www.austin-williams.com 

Great advertising can't be either/or.  It must be .

Plug in to our blog: AW Unplugged
http://www.austin-williams.com/unplugged



-Original Message-
From: Dave Watts [mailto:dwa...@figleaf.com] 
Sent: Tuesday, September 29, 2009 4:00 PM
To: cf-talk
Subject: Re: MySQL Auto Increment Field


 You can also do this using SQL. Sure this works with MS SQL, not 100% sure
 about mySQL but it's standard SQL, so it should work.

 cfquery name=putData datasource=#dsn#
      SET NOCOUNT ON
         INSERT INTO my_table (my_field1, my_field2)
         VALUES ('#trim(value_field1)#', ('#trim(value_field2)#')
      SELECT @@Identity AS newId
      SET NOCOUNT OFF ;
 /cfquery

 cfoutputThe Generated ID is: #putData.newId#/cfoutput

The @@IDENTITY global variable is not standard SQL. It's specific to
T-SQL. So is SET NOCOUNT ON|OFF. Of the four SQL statements you've
listed, one is standard SQL.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326757
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: MySQL Auto Increment Field

2009-09-29 Thread Judah McAuley

And for those folks using MSSQL, please note that @@IDENTITY is
probably not what you want either. @@IDENTITY returns the last
identity produced by a connection to the database, regardless of the
table. So in some circumstances you can end up with an identity
returned that is not from the table you just inserted into. In most
cases you'll instead want to use SCOPE_IDENTITY() which returns the
identity produced by the current connection and current statement
combination.

For more, you can read up here: http://bit.ly/rhkvf

Cheers,
Judah

On Tue, Sep 29, 2009 at 12:59 PM, Dave Watts dwa...@figleaf.com wrote:

 You can also do this using SQL. Sure this works with MS SQL, not 100% sure
 about mySQL but it's standard SQL, so it should work.

 cfquery name=putData datasource=#dsn#
      SET NOCOUNT ON
         INSERT INTO my_table (my_field1, my_field2)
         VALUES ('#trim(value_field1)#', ('#trim(value_field2)#')
      SELECT @@Identity AS newId
      SET NOCOUNT OFF ;
 /cfquery

 cfoutputThe Generated ID is: #putData.newId#/cfoutput

 The @@IDENTITY global variable is not standard SQL. It's specific to
 T-SQL. So is SET NOCOUNT ON|OFF. Of the four SQL statements you've
 listed, one is standard SQL.

 Dave Watts, CTO, Fig Leaf Software
 http://www.figleaf.com/

 Fig Leaf Software provides the highest caliber vendor-authorized
 instruction at our training centers in Washington DC, Atlanta,
 Chicago, Baltimore, Northern Virginia, or on-site at your location.
 Visit http://training.figleaf.com/ for

 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326758
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: MySQL Auto Increment Field

2009-09-29 Thread Robert Harrison

Man. Now I'm glad I posted that. 

Just went through and changed all:

SELECT @@Identity AS newId

To

SELECT SCOPE_IDENTITY() AS newId   

Looks like it worked. I've been using that statement for six or seven years.
Never failed, but I could see where if it did I'd have had no idea what
happened.

Thanks for clearing that up.


Robert B. Harrison
Director of Interactive Services
Austin  Williams
125 Kennedy Drive, Suite 100 
Hauppauge NY 11788
P : 631.231.6600 Ext. 119 
F : 631.434.7022
http://www.austin-williams.com 

Great advertising can't be either/or.  It must be .

Plug in to our blog: AW Unplugged
http://www.austin-williams.com/unplugged


 

__ Information from ESET Smart Security, version of virus signature
database 4468 (20090929) __

The message was checked by ESET Smart Security.

http://www.eset.com
 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326760
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: MySQL Auto Increment Field

2009-09-29 Thread Judah McAuley

I had to go and make that very same change a couple years ago, so I
can totally understand missing that. Glad to be of help.

Cheers,
Judah


On Tue, Sep 29, 2009 at 1:29 PM, Robert Harrison
rob...@austin-williams.com wrote:

 Man. Now I'm glad I posted that.

 Just went through and changed all:

        SELECT @@Identity AS newId

 To

        SELECT SCOPE_IDENTITY() AS newId

 Looks like it worked. I've been using that statement for six or seven years.
 Never failed, but I could see where if it did I'd have had no idea what
 happened.

 Thanks for clearing that up.


 Robert B. Harrison
 Director of Interactive Services
 Austin  Williams
 125 Kennedy Drive, Suite 100
 Hauppauge NY 11788
 P : 631.231.6600 Ext. 119
 F : 631.434.7022
 http://www.austin-williams.com

 Great advertising can't be either/or.  It must be .

 Plug in to our blog: AW Unplugged
 http://www.austin-williams.com/unplugged




 __ Information from ESET Smart Security, version of virus signature
 database 4468 (20090929) __

 The message was checked by ESET Smart Security.

 http://www.eset.com


 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326762
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: MySQL Auto Increment Field

2009-09-29 Thread Dave Watts

While I agree that SCOPE_IDENTITY is the preferred syntax, it's
unlikely that you'll encounter a problem with  @@IDENTITY. CF will use
a single connection for all queries within a page that use the same
datasource, username and password, and the queries will be executed
sequentially unless wrapped in CFTHREAD. So to run into this problem,
you'd have to have a single query doing multiple inserts in a nested
transaction or stored procedure call.

In summary, I would write new T-SQL with SCOPE_IDENTITY, but I
wouldn't bother rewriting existing code.

Dave Watts, CTO, Fig Leaf Software

On 2009-09-29, Judah McAuley ju...@wiredotter.com wrote:

 And for those folks using MSSQL, please note that @@IDENTITY is
 probably not what you want either. @@IDENTITY returns the last
 identity produced by a connection to the database, regardless of the
 table. So in some circumstances you can end up with an identity
 returned that is not from the table you just inserted into. In most
 cases you'll instead want to use SCOPE_IDENTITY() which returns the
 identity produced by the current connection and current statement
 combination.

 For more, you can read up here: http://bit.ly/rhkvf

 Cheers,
 Judah

 On Tue, Sep 29, 2009 at 12:59 PM, Dave Watts dwa...@figleaf.com wrote:

 You can also do this using SQL. Sure this works with MS SQL, not 100%
 sure
 about mySQL but it's standard SQL, so it should work.

 cfquery name=putData datasource=#dsn#
      SET NOCOUNT ON
         INSERT INTO my_table (my_field1, my_field2)
         VALUES ('#trim(value_field1)#', ('#trim(value_field2)#')
      SELECT @@Identity AS newId
      SET NOCOUNT OFF ;
 /cfquery

 cfoutputThe Generated ID is: #putData.newId#/cfoutput

 The @@IDENTITY global variable is not standard SQL. It's specific to
 T-SQL. So is SET NOCOUNT ON|OFF. Of the four SQL statements you've
 listed, one is standard SQL.

 Dave Watts, CTO, Fig Leaf Software
 http://www.figleaf.com/

 Fig Leaf Software provides the highest caliber vendor-authorized
 instruction at our training centers in Washington DC, Atlanta,
 Chicago, Baltimore, Northern Virginia, or on-site at your location.
 Visit http://training.figleaf.com/ for



 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326763
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: MySQL Auto Increment Field

2009-09-29 Thread Agha Mehdi

Thank you all for the great inputs.

On Tue, Sep 29, 2009 at 1:48 PM, Judah McAuley ju...@wiredotter.com wrote:


 I had to go and make that very same change a couple years ago, so I
 can totally understand missing that. Glad to be of help.

 Cheers,
 Judah


 On Tue, Sep 29, 2009 at 1:29 PM, Robert Harrison
 rob...@austin-williams.com wrote:
 
  Man. Now I'm glad I posted that.
 
  Just went through and changed all:
 
 SELECT @@Identity AS newId
 
  To
 
 SELECT SCOPE_IDENTITY() AS newId
 
  Looks like it worked. I've been using that statement for six or seven
 years.
  Never failed, but I could see where if it did I'd have had no idea what
  happened.
 
  Thanks for clearing that up.
 
 
  Robert B. Harrison
  Director of Interactive Services
  Austin  Williams
  125 Kennedy Drive, Suite 100
  Hauppauge NY 11788
  P : 631.231.6600 Ext. 119
  F : 631.434.7022
  http://www.austin-williams.com
 
  Great advertising can't be either/or.  It must be .
 
  Plug in to our blog: AW Unplugged
  http://www.austin-williams.com/unplugged
 
 
 
 
  __ Information from ESET Smart Security, version of virus
 signature
  database 4468 (20090929) __
 
  The message was checked by ESET Smart Security.
 
  http://www.eset.com
 
 
 

 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326764
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: MySQL Auto Increment Field

2009-09-29 Thread Ian Skinner

Dave Watts wrote:
 In summary, I would write new T-SQL with SCOPE_IDENTITY, but I
 wouldn't bother rewriting existing code.

The article did mention trouble coming from the database itself if ones 
insert caused a trigger to be fired.  Then the @@identity could return 
the generated key from what ever the trigger created.

I would presume ColdFusion would provide no protection form this event. 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326765
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4