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.  :)

> -----Original Message-----
> From: Pete Ruckelshaus [mailto:[EMAIL PROTECTED] 
> Sent: Monday, April 03, 2006 9:03 PM
> 
> You are correct.
> 
> 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>
> 
> Pete
> 
> On 4/3/06, Rick Root <[EMAIL PROTECTED]> wrote:
> > I'm looking through someone elses code and I came across this...
> >
> > <cftransaction>
> >        <cfquery name="qInsertData" datasource="#APPLICATION.dsn#">
> >                INSERT INTO t_doctors (#ColNames#)
> >                VALUES (#preserveSingleQuotes(ColValues)#)
> >        </cfquery>
> > </cftransaction>
> > <!--- pull the pkey back out --->
> > <cftransaction>
> >        <cfquery name="get_new_pkey" datasource="#APPLICATION.dsn#">
> >                SELECT @@identity AS newpkey
> >        </cfquery>
> > </cftransaction>
> >
> >
> > having the queries in separate transactions doesn't do 
> anything at all,
> > does it?  Wouldn't the whole thing need to be wrapped in 
> cftransaction
> > for it to be effective/

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:236876
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to