Mysql Execute.EmbeddedScript Failed
See original GitHub issueHi 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:
- Created 4 years ago
- Comments:10 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 itsMySqlScript.Delimiter
property, but I’m not sure how to implement it.EDIT: Clarification
Thank you, removing the delimiter also fixed this issue for me.