How to get data from a server function that executes a query

8 views
Skip to first unread message

sbel...@gmail.com

unread,
Jun 7, 2018, 10:14:15 PM6/7/18
to ruby-pg
Folks,

I'm banging my head on how to SELECT from a server function that executes a query and returns it's results.

What's returned is apparently a text-encoded tuple. But it's not a format that I can parse easily. For example:

"(06f65766-6aca-486f-806b-24972b36cff8,testeece91155e0996ed3990babee359e868XX-8371f81b-010c-433b-a53b-9883855c2124,SomeType,0,1,\"{\"\"attribute\"\": \"\"bde32e7f42426b17f665536b31731987\"\"}\",\"{\"\"metaAttribute\"\": \"\"fd334ca5e1d54743160144ab5da0eb09\"\"}\",\"2018-06-08 01:23:05.114566\")"

Certainly I'm doing something wrong here. If anyone can set me straight, I'd really appreciate it.

Thanks!

Robert Klemme

unread,
Jun 8, 2018, 8:47:19 AM6/8/18
to rub...@googlegroups.com
How is the function defined and how do you query it? Wouldn't you just
do it like in this case?

postgres=# \sf generate_series(integer,integer)
CREATE OR REPLACE FUNCTION pg_catalog.generate_series(integer, integer)
RETURNS SETOF integer
LANGUAGE internal
IMMUTABLE STRICT
AS $function$generate_series_int4$function$
postgres=# select * from generate_series(1,10);
generate_series
-----------------
1
2
3
4
5
6
7
8
9
10
(10 rows)

Cheers

robert

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/

sbel...@gmail.com

unread,
Jun 9, 2018, 3:41:56 PM6/9/18
to ruby-pg
Robert,

Turns out the problem was with the way I was calling the server function. Once I corrected it, everything worked fine.

Thanks!
Scott



Reply all
Reply to author
Forward
0 new messages