Using refcursors in application code (php, python, whatever...) - Mailing list pgsql-general

From Webb Sprague
Subject Using refcursors in application code (php, python, whatever...)
Date
Msg-id b11ea23c0811120712v7c102ee2q543a7c9d45df2487@mail.gmail.com
Whole thread Raw
List pgsql-general
Hi all,

Does anyone have any advice on using application code with a
refcursor? This is a follow up to my "is there a safe-ish way to
execute arbitrary sql" ?  Now that I have way to execute my arbitrary
sql, I need to generate an html table with the arbitrary result inside
some PHP (or whatever), so I need to loop over the results of the
cursor (or do some weird return setof magic which I just figured out).

Sorry to ask here, but I think it is more likely that the readers will
even know what a refcursor is than on a massive php email list.

Here is what I have working in psql:

select query_table_data('select * from mkn_data.datatable_00013', 'boobear');

 query_table_data
------------------
 boobear
(1 row)

mkn=# FETCH FORWARD ALL FROM boobear;
 col1  | col2
-------+------
 bob   |   34
 alice |   32
(2 rows)

Now I need something that says

$curs.fetchall()

pgsql-general by date:

Previous
From: "Grzegorz Jaśkiewicz"
Date:
Subject: Re: sort_mem param of postgresql.conf
Next
From: Jack Orenstein
Date:
Subject: Table bloat and vacuum