I want to execute a Postgres function from Haskell which updates 3 rows but is declared with RETURNS VOID
. I run the function as follows:
catch (do execute conn "select record(?,?)" [id1, id2])
(\(e :: SomeException) -> do putStrLn ("Exception:" ++ (show e)); return False)
but this results in:
QueryError {qeMessage = "execute resulted in Col 1-column result", qeQuery = "select record(?,?)"}
The query doesn't return results:
ebdb=> select record('','');
record
--------------------
(1 row)
How can I execute this Postgresql function from Haskell?
I would try using query
instead of execute
:
query conn "select 1 from record(?,?)" [id1, id2]
execute
is for statements like INSERT
, UPDATE
, etc. Even though your statement does not return any rows, it is still a SELECT
so I think you need to use query
to run it.