Executing the SQL statement is not allowed - Error
Copy link to clipboard
Copied
I am getting "Executing the SQL statement is not allowed" for an INSERT cfquery that I'm running. I checked the usual suspects:
- DSN allows INSERT
- I've seen reports online where certain field names or values are considered key words, so for protection CF blocks the query in this way (it would be nice if there was a different error message when it gets blocked this way vs. the DSN doesn't allow INSERT error message). The field names and values were all benign strings, so it didn't seem like that.
I took the same string for the query and ran it on another page and it ran fine (same DSN, too).
Copy link to clipboard
Copied
SOLVED: I decided to enter this in here, just to get it into web searches for others since I couldn't find anything.
- I was calling a function for one of the values in the query: get_db_status_code("initialize") Apparently CF parses the query to see if it's allowed BEFORE it runs the CFML in it, so something in that function name, or the parameter "initialize" was a key word that CF doesn't allow. I moved the function call outside of the query and loaded a temp variable for use in the query and it then worked.Copy link to clipboard
Copied
To help any searchers, please kindly mark the answer as correct.
Copy link to clipboard
Copied
Since this is the first google result for this error message I thought I'd also add that you will get this error message if the Datasource explicitly disallows the type of SQL statement you're attempting to run. For example if you're attempting to run an UPDATE statement, and the UPDATE checkbox is not turned on, then you will get this error .
To find this setting, edit the DSN and click the "Show Advanced Settings" button.

