I am working on ColdFusion9 and MySQL 5.0. I am not sure why the query name variables get undefined in the insert and update queries, even if I have declared those variables just before the query. Here is the sample code.
<cfset variables.test_update = QueryNew('')>
<cfset variables.res = ''>
<cfquery name="variables.test_update" datasource="dsnTest" result="variables.res">
INSERT INTO test(
name
, rank
)VALUES(
'test'
,23
)
</cfquery>
<cfdump var="#variables.res#">
<cfdump var="#variables.test_update#">
Here the result attribute value is available, but for the query name variable, it is throwing the undefined error, "Element TEST_UPDATE is undefined in VARIABLES."
I know that, the insert, update and delete queries do not return any result set through the query name attribute. But, I am not sure, why does that query name variable get undefined after the query execution?
Please help.
ColdFusion populates variables.test_update
with whatever is returned from the DB driver, which in this case is [nothing].
And CF considers a null variable to be undefined. Always has.