Registers a CFML user-defined function or closure so it can be called by name inside Query of Query (QoQ) SQL. type is scalar (the default) for a per-row function, or aggregate for a function that combines rows (usable with GROUP BY). The registered function stays available for the lifetime of the virtual machine.
queryRegisterFunction(name, udf [, type])
→ returns void
scalarscalaraggregateRegister a function that doubles a column value and use it in QoQ.
q = queryNew("name,score", "varchar,integer");
queryAddRow(q, {name: "Alice", score: 90});
queryAddRow(q, {name: "Bob", score: 75});
queryRegisterFunction("doubleScore", function(score) { return score * 2; });
result = q.query("SELECT name, doubleScore(score) AS doubled FROM q");
writeDump(result);
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.