Is it possible to run multiple sql statements at once?

694 views
Skip to first unread message

Esdras Mayrink

unread,
Jun 20, 2015, 8:48:47 PM6/20/15
to elixi...@googlegroups.com
Hey guys.

I'm trying to run multiple SQL statements in a migration with a single call to execute. I want to execute multiple statements from a file, like this:


But I get this error: ** (Postgrex.Error) ERROR (syntax_error): cannot insert multiple commands into a prepared statement

It seems that Postgrex can't handle multiple statements at once; Is there a way to do this?

I couldn't find how to do it just by looking at the source code.

Thanks.

Esdras Mayrink

unread,
Jun 20, 2015, 9:07:40 PM6/20/15
to elixi...@googlegroups.com
What I ended up doing was mark each statement with a comment and call String.split, like this:


This is fine with me, at least for now, but if you know how to execute multiple statements at once, please let me now.

Thanks.

Eric Meadows-Jönsson

unread,
Jun 20, 2015, 9:19:02 PM6/20/15
to elixi...@googlegroups.com

Postgrex only supports extended queries so you cannot run multiple statements in one query.

--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/b178ac60-6e65-423c-991c-38c0328d1e34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Esdras Mayrink

unread,
Jun 20, 2015, 9:42:40 PM6/20/15
to elixi...@googlegroups.com
Thanks Eric.
Reply all
Reply to author
Forward
0 new messages