From: | vishal saberwal <vishalsaberwal(at)gmail(dot)com> |
---|---|
To: | ctobini <ctemp2(at)free(dot)fr> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Recuperate each line of a result into a variable ? |
Date: | 2005-11-11 05:10:30 |
Message-ID: | 3e74dc250511102110q61c3e8f1peb58f1d5e419b20a@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
if i understand your problem right, you could use a View type as return type
... in this view you declare the fields you want to return ...
thanks,
vish
On 7 Nov 2005 03:15:21 -0800, ctobini <ctemp2(at)free(dot)fr> wrote:
>
> 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2005-11-11 08:08:01 | Re: run vacuum from within a function |
Previous Message | Bob Pawley | 2005-11-11 03:56:27 | Re: Where |