Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I call MySQL stored procedure in ecto(=> 0.11)?

Tags:

mysql

elixir

ecto

I am looking for a way to use call stored procedure, there was no found. Is it possible in an elixir's ecto lib?

like image 254
aposto Avatar asked May 06 '15 03:05

aposto


People also ask

How do I execute a stored procedure in MySQL?

Create a simple stored procedure. DELIMITER ; To create the MySQL Stored Procedure, open the MySQL workbench Connect to the MySQL Database copy-paste the code in the query editor window click on Execute. You can view the procedure under stored procedures.

Can I call a stored procedure from a view in MySQL?

No, you cannot. Views are typically read-only operations; and that behavior cannot be guaranteed if stored-procedures are invoked. Related question: How to call Stored Procedure in a View?


1 Answers

You can go directly through the SQL adapter API:

Ecto.Adapters.SQL.query(YourRepo, "stored_procedure(?, ?)", [param1, param2])

More info here: https://hexdocs.pm/ecto/#!Ecto.Adapters.SQL.html

like image 176
José Valim Avatar answered Sep 24 '22 00:09

José Valim