General developer forum

Coding error detected, it must be fixed by a programmer: moodle_database::execute() Multiple sql statements found or bound parameters not used properly in query!

 
Picture of Konrad Lorinczi
Coding error detected, it must be fixed by a programmer: moodle_database::execute() Multiple sql statements found or bound parameters not used properly in query!
 
Using Moodle v2.7.20.
Developing plugin with backward version compatibility.


I get the following error:

Coding error detected, it must be fixed by a programmer: 
moodle_database::execute() Multiple sql statements found or bound 
parameters not used properly in query!

, when executing the following db code:

              $sql = "
CREATE FUNCTION `_increase_num` () RETURNS int(11)
RETURNS INT
READS SQL DATA
DETERMINISTIC
BEGIN
RETURN IF(@counter, @counter:=@counter+1, @counter:=1);
END";
$result = $DB->execute($sql);
Any idea, what I'm doing wrong?
 
Average of ratings: -
Davo
Re: Coding error detected, it must be fixed by a programmer: moodle_database::execute() Multiple sql statements found or bound parameters not used properly in query!
Group Core developersGroup Particularly helpful MoodlersGroup Plugin developers

Moodle is objecting to the presence of the ';' inside the SQL statement.

You will need to rewrite what you are attempting to do without the semicolon.


 
Average of ratings: Useful (1)
Picture of Konrad Lorinczi
Re: Coding error detected, it must be fixed by a programmer: moodle_database::execute() Multiple sql statements found or bound parameters not used properly in query!
 
I was able to shorten the query, then worked!
Thanks!
 
Average of ratings: -