Years ago i picked up a way of returning the value inserted into an
Identity column in SQL server, by adding a trigger to that table:
CREATE TRIGGER get_my_id ON dbo.my_table
FOR INSERT
AS
SELECT my_id AS my_new_id
FROM INSERTED
GO
Then i can run:
<cfquery name="q_test" datasource="#dsn#">
INSERT INTO my_table (my_text)
VALUES ('foo')
</cfquery>
my new id = #q_test.my_new_id#
I know i can use @@IDENTITY or SCOPE_IDENTITY(), but i was wondering
if the trigger method is a Bad thing to do...
Its worked from CF4 to CFMX7, but barfs with the DataDirect 3.4
drivers: the insert happens, but JRun sits at 50%.
Does that mean there's a bug with the driver, or something wrong with my code?
Cheers
Bert
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:212301
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