Slick 3: Calling PostgreSQL stored procedure with sqlu causes SlickException

774 views
Skip to first unread message

Craig Smitham

unread,
May 19, 2015, 11:42:12 PM5/19/15
to scala...@googlegroups.com
If I call a PostgreSQL 9.4 PL/pgSQL stored procedure with a void return type using sqlu:

sqlu"SELECT my_stored_procedure($param)"

The stored procedure successfully executes by the db, but Slick throws a SlickException: Update statements should not return a ResultSet

If I change the stored procedure to have an explicit return type, such as Boolean, and return that in the PL/pgSQL function, and call the slick code with sql, then Slick is fine:

sql"SELECT my_stored_procedure($param)".as[Boolean]

I can get by with the latter syntax, but it's not idiomatic Slick (if I'm not mistaken). Is this a bug, or is there a better way to call a stored procedure and avoid this exception?

Anze Cesar

unread,
May 20, 2015, 2:04:17 PM5/20/15
to scala...@googlegroups.com
You can define your function:
val uuidTimestamp = SimpleFunction.unary[UUID, LocalDateTime]("uuid_timestamp")
for example, then call it as you would any other function (min, max, ...):
.sortBy(x => uuidTimestamp(x.id).asc)
uuid_timestamp in this case is a custom function I defined in Postgres.



--

---
You received this message because you are subscribed to the Google Groups "Slick / ScalaQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaquery+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalaquery/0ac68e76-718b-4968-9229-66bc877169a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Craig Smitham

unread,
May 20, 2015, 7:10:39 PM5/20/15
to scala...@googlegroups.com
I don't think that was the answer to my question, wrong thread?

Dave Stevens

unread,
Aug 31, 2015, 4:01:07 PM8/31/15
to Slick / ScalaQuery
I'm having trouble figuring this out as well. Were you ever able to find a solution?

党凡

unread,
Oct 14, 2015, 4:22:09 AM10/14/15
to Slick / ScalaQuery
So am I. Is there any working solution?

在 2015年9月1日星期二 UTC+8上午4:01:07,Dave Stevens写道:

Craig Smitham

unread,
Oct 14, 2015, 4:09:57 PM10/14/15
to Slick / ScalaQuery
I have not tried with 3.1 - maybe the issue was fixed? If not I plan to submit a GitHub issue. 

党凡

unread,
Oct 15, 2015, 12:37:49 AM10/15/15
to Slick / ScalaQuery
It's still the same.

在 2015年10月15日星期四 UTC+8上午4:09:57,Craig Smitham写道:

Aaron Patzer

unread,
Aug 30, 2019, 11:13:26 AM8/30/19
to Slick / ScalaQuery
There is no support to return `.as[Unit]` so you need to return `.as[String]`. The result of a void function will be an empty string.
 => sql"SELECT my_stored_procedure($param)".as[String]
Should work fine.


On Tuesday, May 19, 2015 at 11:42:12 PM UTC-4, Craig Smitham wrote:
Reply all
Reply to author
Forward
0 new messages