I was trying to use QueryAddColumn() today to add an additional column to a single-row array I’m working with. The 4th parameter to QueryAddColumn is an array of values to add to the query – 1 element in the array for each row in the query. Since my query only has on row in it, I thought this would be a good place to use ColdFusion 8’s new inline array syntax.
<cfset QueryAddColumn(qryFoo,
"newColName",
"varchar",
["my additional value"])>
But this throws an unhelpful “Missing argument name” error:
Missing argument name. When using named parameters to a function, every parameter must have a name.
It took me a while to figure out it just didn’t like using the new array syntax inside the function. Doing it this way worked fine:
<cfset myArray = ["my additional value"]>
<cfset QueryAddColumn(qryFoo,"newColName","varchar",myArray)>
But having to do it that way kind of defeats the point, it doesn’t use any less lines than the old CF7 syntax:
<cfset myArray[0] = "my additional value">
<cfset QueryAddColumn(qryFoo,"newColName","varchar",myArray)>
And it means I have to “var” the myArray variable at the top of my function now. Hopefully Adobe will get this straightened out at some point.