I have a query that does a select/insert:
INSERT INTO myTable (...) SELECT (...) FROM theOtherTable WHERE 1=1
I was trying to figure out what was going on in this query but doing a simple cfdump of ‘data’ was throwing an error (btw this is on CF8). Reading the docs I noticed there is a “results” attribute:
Specifies a name for the structure in which
cfqueryreturns the result variables.
So I modified my query to add a result and then dumped that and it worked!
<cfquery name=”data” result=”testdata”>
<cfdump var=”#testdata#”>
Hopefully this is helpful to others…
@Jim
One other thing that you may find very useful to know is that the result will also hold the primary key when you’re performing an INSERT statement. This is great if you need to have a cfc return the primary key and your table is using IDENTITY (SQL Server) or Auto-Increment (MySQL).
you can also try
INSERT INTO myTable (…)
OUTPUT INSERTED.*
SELECT (…)
FROM theOtherTable
WHERE 1=1
output command also works for updated, deleted