List:General Discussion« Previous MessageNext Message »
From:Jerry Schwartz Date:January 24 2011 3:42pm
Subject:RE: CURRENT insert ID
View as plain text  
I'll have to investigate how to do a transaction from Access. I guess 
pass-through queries might do it, but I'm not sure.

>-----Original Message-----
>From: Carsten Pedersen [mailto:carsten@stripped]
>Sent: Sunday, January 23, 2011 9:36 AM
>To: Jerry Schwartz
>Cc: 'mysql.'
>Subject: Re: CURRENT insert ID
>
>Seeing from later posts that you're using InnoDB, why don't you simply
>wrap the INSERT/UPDATE into a transaction? You don't avoid the UPDATE,
>but I'm not sure I understand the need to mess w/ triggers.
>
>BEGIN
>INSERT INTO t(id) NULL
>UPDATE t SET xxx=last_insert_id()
>COMMIT
>
[JS] I'll have to investigate how to do a transaction from Access. I guess 
pass-through queries might do it, but I'm not sure.

Regards,

Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341
E-mail: jerry@stripped
Web site: www.the-infoshop.com



>Best,
>
>/ Carsten
>
>Den 21-01-2011 17:41, Jerry Schwartz skrev:
>> Here it is in a nutshell:
>>
>>
>>
>> I have a field that needs to be set equal to the auto-increment ID as a
>record is entered. I don't know how to do this without a subsequent UPDATE
>(which I can do with a trigger). Is there any way to avoid the cost of an
>UPDATE?
>>
>>
>>
>> Here's a more concrete description of the problem:
>>
>>
>>
>> CREATE TABLE t (
>>
>> id INT(11) AUTO-INCREMENT PRIMARY,
>>
>> xxx INT(11)
>>
>> );
>>
>>
>>
>> When a record is added to table `t`, I need to set `xxx` to the value
>generated for `id`. (`xxx` might be changed later.)
>>
>>
>>
>> Is there anything clever I can do?
>>
>>
>>
>> Regards,
>>
>>
>>
>> Jerry Schwartz
>>
>> Global Information Incorporated
>>
>> 195 Farmington Ave.
>>
>> Farmington, CT 06032
>>
>>
>>
>> 860.674.8796 / FAX: 860.674.8341
>>
>> E-mail:<mailto:jerry@stripped>  jerry@stripped
>>
>> Web site:<http://www.the-infoshop.com/>  www.the-infoshop.com
>>
>>
>>
>>



Thread
CURRENT insert IDJerry Schwartz21 Jan
  • Re: CURRENT insert IDjoao21 Jan
    • Re: CURRENT insert IDDarryle Steplight21 Jan
  • Re: CURRENT insert IDjoao21 Jan
    • RE: CURRENT insert IDJerry Schwartz21 Jan
      • Re: CURRENT insert IDDonovan Brooke22 Jan
        • Re: CURRENT insert IDJesper Wisborg Krogh22 Jan
        • RE: CURRENT insert IDJerry Schwartz24 Jan
          • Re: CURRENT insert IDMark Goodge24 Jan
      • Re: CURRENT insert IDJaime Crespo Rinc√≥n24 Jan
  • Re: CURRENT insert IDCarsten Pedersen23 Jan
    • Re: CURRENT insert IDCarsten Pedersen23 Jan
    • RE: CURRENT insert IDJerry Schwartz24 Jan
Re: CURRENT insert IDMichael Dykman21 Jan
  • RE: CURRENT insert IDJerry Schwartz21 Jan
    • RE: CURRENT insert IDJerry Schwartz21 Jan
      • RE: CURRENT insert IDJerry Schwartz21 Jan
      • Re: CURRENT insert IDMichael Dykman21 Jan
        • RE: CURRENT insert IDJerry Schwartz21 Jan