question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mysql Execute.EmbeddedScript Failed

See original GitHub issue

Hi I just wanted to create a function in Mysql.

Sql Script Content test.sql

DELIMITER $$
CREATE DEFINER=`user`@`localhost` FUNCTION `fn_first_day`(
`Any_date` DATE
)
RETURNS date
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
Declare retu varchar(20) ;
SET @started=TRUE;
set retu =DATE_FORMAT(Any_date ,'%Y-%m-01');
  RETURN cast(retu as date) ;
END$$
DELIMITER ;

I am using the Execute.EmbeddedScript as follows Execute.EmbeddedScript("App.Migrator.Migrators.test.sql");

and I am getting the following error from Mysql

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 'DELIMITER $$

DROP PROCEDURE IF EXISTS proc_getCompany_det$$ CREATE DEFINER’ at line 1

The script is working perfectly in MysqlWorkbench I double checked, that the file is embedded in the assembly

       // checking the embeded file is there ?
	var asm = typeof(App.Migration.Migrators.Migartion201910050542).Assembly;
        foreach (var n in asm.GetManifestResourceNames())
                   Console.WriteLine("Embeded file :"+ n)

What is wrong with my code? Please help

Mysql Ver .5.7 on Ubuntu 18.04 Dotnet Framework : 4.6.1 FM Version : 3.2.1

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
fubar-codercommented, Nov 5, 2019

My assumption is that the ADO.NET driver doesn’t support DELIMITER. I checked it and we’re not splitting the SQL commands for MySQL, so it shouldn’t be a problem on our side.

This Stack Overflow question: C#, MySQL, ADO.NET, delimiter causing syntax error points to a bug report, but this issue is for the MySqlScript class which we’re not using. You may find a workaround (albeit an ugly one) in this Stack Overflow question: Mysql delimiter syntax error only get error on c#.

The best solution would be to use MySqlScript with its MySqlScript.Delimiter property, but I’m not sure how to implement it.

EDIT: Clarification

1reaction
ezsoftwarecommented, Dec 1, 2020

Thank you, removing the delimiter also fixed this issue for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix en error when running an SQL Script in MySQL ...
3 Answers 3 ... In the MySQLWorkbench, instead of File > Run SQL Script, could you try to use File > Open SQL...
Read more >
Fluent Interface | FluentMigrator documentation
Allows you to execute a block of sql, or a script by name (ie. myscript.sql) or an embedded sql script. To embed an...
Read more >
Issue with MySQL script not executing - always returns error
I am trying to run a simple MySQL script as part of the install process, to register the user in a table, on...
Read more >
104947: Unable to run SQL scripts from file>run script
log] When we try to run a SQL script from file> run script, we get this error "[WinError 32] The process cannot access...
Read more >
Advertising Reach developers & technologists worldwide ...
0 DomPDF Failed To Generate PDF from Simple HTML Bootstrap How to separate a face at one edge ... I created a dompdf...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found