I am curious, does the query use the NOCOUNT and @@identity SQL commands??

<cfquery name="addAgent">
SET NOCOUNT ON
insert into users_printprofiles
(                       
)
values(
)
select newid=@@identity
SET NOCOUNT OFF
</cfquery>

Brook


-----Original Message-----
From: Michael Dinowitz [mailto:mdino...@houseoffusion.com] 
Sent: January-27-10 1:26 PM
To: cf-talk
Subject: Re: CF9 cfquery not giving same insert results as CF7


OK, so it turns out that this is a known issue that came into effect between
CF 7 and CF 8. I can do one of three things here. 

1. replace the name attribute with the result attribute:
<cfquery name="AddAgent"> becomes <cfquery result="AddAgent">

2. add a result attribute of the same name to the cfquery
<cfquery name="AddAgent"> becomes <cfquery name="AddAgent"
result="AddAgent">

3. use a 'generic' result value to the cfquery
<cfquery name="AddAgent"> becomes <cfquery name="AddAgent"
result="QueryResult">

The problem that I see is that I don't know everywhere that the query
results will be used. 
Is anything returned to the 'name' variable of the query? If not, then will
removing it cause some other unforeseen effect? (experiments so far say no)
Will the use of both a name and a result conflict? (experiments so far say
no)
How will all this interact with Fusebox? Is the results of a query in an
act_ page supposed to be 'exposed' to the dsp_ page?

If anyone has a clue or two on which way I should go on this, please let me
know. I've got to fix this in almost 700 places (the client site is a royal
mess of backed up and copied code) and a single, standard approach is what I
need. Luckily, the RegEx to find all of the locations took 60 seconds to
write. Literally.

The hard is fast, the easy is slow. How standard for me. :)

--
Michael

>I just ran into this and while it's new to me, I'm sure it's old news
>to others here. I'm looking at someones code from CF 7 where they have
>a cfquery inserting a record. The cfquery tag only has a name and a
>datasource. Immediately after the tag, there is a cfset that makes use
>of the query's name and the name of the identity field of the table
>that the data was inserted into.
>
><cfquery name="testquery" datasource="test">
>insert ...
></cfquery>
><cfset newid = testquery.identityfield>
>
>In CF 7, the newid would be the id of the newly inserted record. In CF
>9 all I get is an error. If I use a result attribute rather than a
>name attribute, I get a structure with the identity result buried in
>it.
>
>So here's the question. If it worked in 7 and not in 9, is there a
>simple fix to make it work like it did in 7 again? I'd rather not have
>to recode a whole slew of insert statements.
>
>Thanks
>
>--
>Michael 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:330198
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to