Thursday, December 27, 2018

ColdFusion - using a colon in sql with queryexecute

queryexecute doesn't seem to allow escaping colons in sql.
Using MySQL regexp character classes will throw an error if entered in the sql directly.
A workaround is to add the regex expression as a queryparam.

The following will throw an error:
queryexecute("SELECT [column] REGEXP '[[:character-class:]]'...");

Here's the workaround:
queryexecute("SELECT [column] REGEXP :regex...",{regex:{value:"'[[:character-class:]]'"}});