I'm not sure about MySQL, but in Postgres you can select a new identity
key /before/ you do an insert.  The key is unique to you, and can never
be used by anybody else (just like getting a new key when you do an
insert).  Then you can use that key for your insert and any subsequent
queries.  Much safer than Microsft's approach, where you have to
scramble to safely get the key from a recent insert.

> -----Original Message-----
> From: Joelle Tegwen [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, April 04, 2006 9:11 AM
> 
> How would you to this in (say) MySQL?
> 
> Munson, Jacob wrote:
> > Keep in mind that most other databases (besides SQL Server) 
> don't allow
> > you to send two queries with at once like this.  It's very insecure,
> > because of sql injection possibilities.  But since you guys are all
> > talking about MS SQL, this works fine.  :)
> >   
> >> Moreover, a better solution would be something like this 
> >> (assuming SQL Server):
> >>
> >> <cftransaction>
> >>        <cfquery name="qInsertData" datasource="#APPLICATION.dsn#">
> >>                INSERT INTO t_doctors (#ColNames#)
> >>                VALUES (#preserveSingleQuotes(ColValues)#);
> >>                SELECT  SCOPE_IDENTITY() AS newpkey;
> >>        </cfquery>
> >> </cftransaction>

This transmission may contain information that is privileged, confidential 
and/or exempt from disclosure under applicable law. If you are not the intended 
recipient, you are hereby notified that any disclosure, copying, distribution, 
or use of the information contained herein (including any reliance thereon) is 
STRICTLY PROHIBITED. If you received this transmission in error, please 
immediately contact the sender and destroy the material in its entirety, 
whether in electronic or hard copy format. Thank you. A1.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:236907
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to