-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Recently added (in #26) executeMany_ function allows to perform multiple statements, which is great! Unfortunately, it fails when I'm trying to use this function to create procedure in MySQL.
I see the following error:
ERRException (ERR {errCode = 1064, errState = "42000", errMsg = "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 //\nCREATE PROCEDURE simpleproc (OUT param1 INT)\nBEGIN\n SELECT COUNT' at line 1"})However, if I execute my query from MySQL REPL, everything works great 👍
I'm following this guide:
As I understand, the problem is in DELIMITER command. I wonder, whether it's possible to somehow support this workflow in mysql-haskell library? 🤔
And here is complete code:
#! /usr/bin/env cabal
{- cabal:
build-depends: base >= 4.11 && < 4.12
, mysql-haskell ^>= 0.8.4.1
-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.String (fromString)
import Database.MySQL.Base
import Database.MySQL.Connection (utf8mb4_unicode_ci)
createProc :: Query
createProc = fromString $ unlines
[ "DELIMITER //"
, "CREATE PROCEDURE simpleproc (OUT param1 INT)"
, "BEGIN"
, " SELECT COUNT(*) INTO param1 FROM t;"
, "END //"
, "DELIMITER ;"
]
main :: IO ()
main = do
(greet, conn) <- connectDetail ConnectInfo
{ ciHost = "localhost"
, ciPort = 3306
, ciUser = "mp"
, ciPassword = "mp"
, ciDatabase = "mp"
, ciCharset = utf8mb4_unicode_ci
}
print greet
print =<< mapM (executeMany_ conn) [createProc]Metadata
Metadata
Assignees
Labels
No labels