Hello Everyone,
Question regarding the query below. I'm using it on an Access2000 db.
The insert is executed on one table and the select is set to retrieve the new
primary key and update a recording in a different table. My first guess, using
UNION to join the two queries, is not working. One option I think is to take
it out of the cfc and put it in the action page, with a cfoutput between the
SELECT and UPDATE. But I'd rather keep it in the cfc, mostly because I'm
obstinate.
Thanks in advance to anyone who can help.
John
<cffunction name="NewSubject2"
returntype="boolean">
<cfargument name="NewSubject2"
type="string">
<cfargument name="lpId"
type="numeric">
<cftransaction>
<cfquery name="newSubject2"
datasource="#APPLICATION.datasource#">
INSERT INTO Subjects (Subject)
VALUES ('#Trim(ARGUMENTS.NewSubject1)#')
</cfquery>
<cfquery name="qGetNewSubjectId"
datasource="#APPLICATION.datasource#">
SELECT MAX(SubjectPk) AS NewSubjPk
FROM Subjects
UNION
UPDATE LessonPlan
SET Subject2 = #NewSubjPk#
WHERE LessonPlan = #ARGUMENTS.lpId#
</cfquery>
</cftransaction>
</cffunction>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs
http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU
Archive:
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:2473
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15