Pgsql problem

Started by pasman pasmańskiabout 14 years ago4 messagesgeneral
Jump to latest
#1pasman pasmański
pasman.p@gmail.com

Hi.

I write function in pgsql. This function needs
to execute other functions by name.
I do it using loop:

declare r record;
begin
for r in execute 'select ' || $1 || '()'
loop
end loop;

But I can't convert a record to array of text.
How to do it ?

------------
pasman

#2Dmitriy Igrishin
dmitigr@gmail.com
In reply to: pasman pasmański (#1)
Re: Pgsql problem

Hey pasman,

2012/1/12 pasman pasmański <pasman.p@gmail.com>

Hi.

I write function in pgsql. This function needs
to execute other functions by name.
I do it using loop:

declare r record;
begin
for r in execute 'select ' || $1 || '()'
loop
end loop;

But I can't convert a record to array of text.
How to do it ?

Presently, hstore is a most flexible solution in such cases.
See http://www.postgresql.org/docs/9.1/static/hstore.html

--
// Dmitriy.

#3Achilleas Mantzios
achill@smadev.internal.net
In reply to: pasman pasmański (#1)
Re: Pgsql problem

On Πεμ 12 Ιαν 2012 12:51:00 pasman pasmański wrote:

Hi.

I write function in pgsql. This function needs
to execute other functions by name.
I do it using loop:

declare r record;
begin
for r in execute 'select ' || $1 || '()'
loop
end loop;

But I can't convert a record to array of text.
How to do it ?

Maybe you should a look at array_agg. It is an aggregate function operating on
a set of values and returning the resulting array.

http://www.postgresql.org/docs/9.0/interactive/functions-aggregate.html

------------
pasman

--
Achilleas Mantzios
IT DEPT

#4pasman pasmański
pasman.p@gmail.com
In reply to: Achilleas Mantzios (#3)
Re: Pgsql problem

Thanks.

Hstore works perfectly.

------------
pasman