| From: | "ctobini" <ctemp2(at)free(dot)fr> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Recuperate each line of a result into a variable ? |
| Date: | 2005-11-07 11:15:21 |
| Message-ID: | 1131362120.986511.149360@g43g2000cwa.googlegroups.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hello,
I would like to know how to recuperate the results of a request.
I read the O'Reilly book about Postgresql and and know there are 2 ways
in PL/pgSQL to do that :
1.
declare
variable type;
select into variable column for table where...
2.
declare
variable table%ROWTYPE
for variable in select * from table where...
What I want to do is to make a multitable request and to recuperate
each line of the result by stocking a number or text into variable
eg with int;
declare
sum int := 0;
for variable in select count(distinct sold), name from books natural
join authors... loop
sum = sum + sum; ...
eg with text
declare
list text := '''':
variable as text;
for variable in select title from books natural join authors... loop
if
variable like ''The%''
list := list || variable.title || ''\n'' ...
Thanks.
C. Tobini
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Guido Neitzer | 2005-11-07 11:50:18 | PostgreSQL, UTF-8 and Mac OS X |
| Previous Message | Michael Glaesemann | 2005-11-07 10:15:09 | Re: Aggregates, group, and order by |