MySQL delimiter syntax error
DELIMITER
is not a MySQL command. It's a command that your MySQL client needs to support. I was running PHPMyAdmin 2.8.2.4, which didn't support it. When I upgraded to the newest version, which is currently 3.4.9, it worked just fine. Your MySQL version has nothing to do with DELIMITER
and whether it's supported or not.
Syntax error near $$DELIMITER
I figured what was wrong, and it wasn't only about "DELIMITER" but with a couple things more...
Here is the fixed code:
CREATE PROCEDURE entradas_sai (
IN ID_VEICULO VARCHAR(45), OUT retcode INT)
BEGIN
DECLARE _rollback BOOL DEFAULT 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET _rollback = 1;
START TRANSACTION;
INSERT INTO SAIDAS(data, hora) VALUES(date(now()) ,time(now()));
UPDATE ENTRADAS SET SAI=1;
IF '_rollback' THEN
SET retcode = 0;
ROLLBACK;
ELSE
SET retcode = 1;
COMMIT;
END IF;
END $$
Steps: Removed the "Delimiter $$" and "Delimiter ;" and then restructured the UPDATE query. That was the main problem, because the syntax wasn't on the spot... Thanks all who tryied to help.
In this case the value of "1" wasn't the value i want... So, i changed it to @sai, which means that the value is given at a button click, which is a increment of the parameter @sai, being equal to 1,2,3,4 and so on.
MySQL DELIMITER syntax errors
Try
DELIMITER ;
not
DELIMITER;
You're actually specifying ;
as an argument to the DELIMITER
command, so not having the space there may be confusing it.
mysql delimiter error
I would remove the semicolon after END
.
...
END
|
DELIMITER ;
Re your comment, you can't use the current delimiter when declaring a new delimiter. That sounds confusing, but consider if you do this:
DELIMITER |;
Now MySQL would think the delimiter is "|;" (two characters, a pipe and a semicolon). If you think about it, DELIMITER
must be treated in a special way by the MySQL client. It's the only statement that can't be followed by the current delimiter.
So when setting the delimiter to pipe, do this:
DELIMITER |
When setting it back to semicolon, do this:
DELIMITER ;
FWIW, I ran the following with no error on my local test database on MySQL 5.0.75:
DROP FUNCTION IF EXISTS PersonName;
DELIMITER |
CREATE FUNCTION PersonName( personID SMALLINT )
RETURNS CHAR(20)
BEGIN
DECLARE pname CHAR(20) DEFAULT '';
SELECT name INTO pname FROM family WHERE ID=personID;
RETURN pname;
END
|
DELIMITER ;
fixing Mysql Delimiter syntax error in testcontainers init script
So the best way is to copy the sql file to the container and have it executed in the initialization of the container with /docker-entrypoint-initdb.d. This is the recommendation by sql team. So this is how to achieve it.
private static final MySQLContainer database = new MySQLContainer("mysql:8");
static {
try {
database.withCopyFileToContainer(MountableFile.forClasspathResource("schema2.sql"), "/docker-entrypoint-initdb.d/schema.sql");
database.start();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
Delimeter not working, Syntax errors when running .sql from shell
Of course you can , but with the right keywords
DELIMETER
-> DELIMITER
PORCEDURE
-> PROCEDURE
Error with MySQL syntax in event sql-script. Delimeter already used
I guess you tried to run this using JDBC?
You don't need DELIMITER |
at all. That's a mysql client builtin command. Client builtins are not recognized by the SQL parser.
You can just execute the CREATE EVENT
statement as a single statement and then you don't need to have a delimiter at the end of the statement. Delimiters are only important in interfaces that support multiple statements (e.g. the mysql client).
Okay it seems you are using multiple statements in an .sql
file and you need some way of separating the statements. Normally this is ;
but you have some statements that contain ;
as part of the statement, not as the separator.
I'm not a Spring developer, but I found Spring Boot Database initialization MySQLException for Trigger which describes the use of:
spring.datasource.separator
This is also documented: https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html
spring.datasource.separator
(default)
;
Statement separator in SQL initialization scripts.
syntax error: 'delimiter ' is not valid input here
Your problem is not the line
DELIMITER //
but the line
delimiter;
You've left out a space; it should be
delimiter ;
Related Topics
Lost the Intellisense in SQL Server Management Studio
Stored Procedure Parameter Default Value - Is This a Constant or a Variable
Spring Boot Query Annotation with Nativequery Doesn't Work in Postgresql
Workaround for Ora-00997: Illegal Use of Long Datatype
How to to Read a Xml from a Url Using T-Sql
Subquery in SQL Server Compact Edition
Stop MySQL Reusing Auto_Increment Ids
"Pivot" Table Oracle - How to Change Row Items into Columns
Sql, Postgres Oids, What Are They and Why Are They Useful
The Argument 1 of the Xml Data Type Method "Value" Must Be a String Literal
Does Limiting a Query to One Record Improve Performance
Run Stored Procedure and Return Values from Vba
SQL Oracle Left Join and Subquery Error: Ora-00905: Missing Keyword
How to Select a List of 10,000 Unique Ids from Dual in Oracle SQL
Window Functions: Partition by One Column After Order by Another
How to Have a Tableless Select with Multiple Rows
Calling Stored Procedure While Passing Parameters from Access Module in Vba