Hi,
I need to store the result of select into an array of string:
/create or replace function search_engine.test/
/(/
/)/
/returns integer as $$/
/declare/
/m_array text[];/
/begin/
/for m_array in select * from my_table loop/
/raise notice
In response to Alberto Asuero Arroyo :
Hi,
I need to store the result of select into an array of string:
test=*# select * from foo;
t
--
foo
bar
batz
(3 rows)
test=*# select array_agg(t) from foo;
array_agg
{foo,bar,batz}
(1 row)
Helps that?
Andreas
--
Hello.
You should use an array constructor:
DECLARE
m_array text[];
[..]
BEGIN
FOR m_array IN SELECT ARRAY[col_1, col_2, col_N] FROM my_table LOOP
[..]
END LOOP;
Regards,
Igrishin Dmitriy.
2009/10/9 Alberto Asuero Arroyo albertoasu...@gmail.com
Hi,
I need to store the result of
Dmitriy Igrishin wrote:
Hello.
You should use an array constructor:
DECLARE
m_array text[];
[..]
BEGIN
FOR m_array IN SELECT ARRAY[col_1, col_2, col_N] FROM my_table LOOP
[..]
END LOOP;
Regards,
Igrishin Dmitriy.
2009/10/9 Alberto Asuero Arroyo albertoasu...@gmail.com
Consider the attached schema (filmstars.sql), which is a poorly designed
database of films and actors. The following query gives me a list of
films in which either Charlie or Martin Sheen starred:
select fs.film.title, fs.film.year
from fs.film left join fs.star on fs.film.id = fs.star.film
On Sat, 10 Oct 2009, [utf-8] Dag-Erling Sm??rgrav wrote:
Consider the attached schema (filmstars.sql), which is a poorly designed
database of films and actors. The following query gives me a list of
films in which either Charlie or Martin Sheen starred:
select fs.film.title, fs.film.year
you could use distinct on
select distinct on (fs.film.title, fs.film.year ) title, year
from fs.film left join fs.star on fs.film.id = fs.star.film
where fs.star.last = 'Sheen';
On Sat, 2009-10-10 at 00:53 +0200, Dag-Erling Smørgrav wrote:
Consider the attached schema (filmstars.sql), which
Richard Albright ralbri...@insiderscore.com writes:
you could use distinct on
select distinct on (fs.film.title, fs.film.year ) title, year
from fs.film left join fs.star on fs.film.id = fs.star.film
where fs.star.last = 'Sheen';
Thanks, I didn't know about distinct on. This version uses
Stephan Szabo ssz...@megazone.bigpanda.com writes:
Not at all tested as I don't have access to my db right now, but I think
something like one of these would work:
select fs.film.title, fs.film.year
from fs.film
where exists(select 1 from fs.star where fs.film.id = fs.star.film
and
On Sat, 10 Oct 2009, [utf-8] Dag-Erling Sm??rgrav wrote:
Stephan Szabo ssz...@megazone.bigpanda.com writes:
Not at all tested as I don't have access to my db right now, but I think
something like one of these would work:
select fs.film.title, fs.film.year
from fs.film
where
10 matches
Mail list logo