MySQL:
<cfquery result="insertrow" datasource="#application.ds#">
INSERT INTO [table]([column1], [column2]...)
VALUES([value1], [value2]...)
</cfquery>
ID: insertrow.generated_key
INSERT INTO [table]([column1], [column2]...)
VALUES([value1], [value2]...)
</cfquery>
ID: insertrow.generated_key
T-SQL
<cfquery name="insertrow" datasource="#application.ds#">
INSERT INTO [table]([column1], [column2]...)
VALUES([value1], [value2]...)
SELECT @@IDENTITY AS id
</cfquery>
ID: insertrow.id
INSERT INTO [table]([column1], [column2]...)
VALUES([value1], [value2]...)
SELECT @@IDENTITY AS id
</cfquery>
ID: insertrow.id
Notice that when using MySQL, you use result, while when using T-SQL you use name.
No comments:
Post a Comment