PDO and delimiters.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I am executing some statements on a MySQL db via PDO::exec($statement).
Other statements work fine on the database, e.g. creating tables.
However, anything with the line "DELIMITER ;;" fails with a message:
"You have an error in your SQL syntax; check the manual... etc"

This is important because I need to create stored procedures on a
database from a script, which requires using a different delimiter.

I have, just for completeness, tried using a different delimiter than ;;
but I get the same error message.

I'm quite prepared for this to be a stupid mistake on my part, I just
need to get this script working, asap.

Many thanks,


Re: PDO and delimiters.

Quoted text here. Click to load it

 From the manual: the DELIMITER statement is not an SQL statement, but a
keyword in mysql command-line client. It only serves to tell that
command-line client to treat more than one line as one statement, even
though the lines may end with a semicolon.

Quoted text here. Click to load it

It should not require that. Any library that can send multi-line queries
as one should send it correctly. From the top of my head, PDO should
work fine if you remove the DELIMTER statements and off course the
occurrence of your new delimiter.

Alternatively, use the mysql command-line client for that script.

Best regards,
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl /

Re: PDO and delimiters.

Willem Bogaerts wrote:
Quoted text here. Click to load it

Thank you. You were entirely correct, I didn't need to change the
delimiter after all. I've been so used to doing things via the command
line that I forgot delimiters weren't necessary in this case. I also got
myself slightly confused because PDO::Query(...) actually accepts
DELIMITER without an error. :/

Anyway, I kick myself now. Thanks very much for the quick response,


Site Timeline