Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does MySQL refuse pipe ('|') character in string on INSERT INTO

Tags:

sql

mysql

If I try this statement:

INSERT INTO TerminalEventChild (id,stringValue) VALUES 
(64,'version123|');

MySQL fail with :

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''version123' at line 1
SQLState:  42000
ErrorCode: 1064

If I remove the | character, everything works fine. Any idea?

like image 214
Manuel Darveau Avatar asked Mar 24 '10 19:03

Manuel Darveau


2 Answers

I found the solution on Incorrect query parsing - ID: 3091322.
Squirrel SQL is using the pipe symbol as a procedure/function separator, so you need to change the MySQL preferences to use something else (e.g. |||).

In the "File > Global Preferences > MySQL" tab, in the "Procedure/Function Separator" field, replace | with a different string, for example |||.

like image 111
Anne Marie Avatar answered Oct 13 '22 04:10

Anne Marie


On my machine, this works fine:

CREATE TABLE TerminalEventChild (id INT, stringValue VARCHAR(200));

INSERT INTO TerminalEventChild (id,stringValue) VALUES
(64,'version123|');

Probably, your client treats the pipe character specially.

What client do you use?

like image 20
Quassnoi Avatar answered Oct 13 '22 03:10

Quassnoi