| From: | Nick Jones <neckjonez(at)gmail(dot)com> | 
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, desoi(at)pgedit(dot)com | 
| Cc: | pgsql-novice(at)postgresql(dot)org | 
| Subject: | Re: Functions | 
| Date: | 2005-05-31 18:52:01 | 
| Message-ID: | be082070050531115223fd0151@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
Aww, I was really close :) ... thanks, that works. I believe I understand it 
now :) Do you normally write functions in plpgsql or a different language 
(sql, perl, c)? I ask so I should know where to focus my learning.
Thanks,
Nick
On 5/31/05, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> 
> Nick Jones <neckjonez(at)gmail(dot)com> writes:
> > CREATE FUNCTION test2(VARCHAR) RETURNS SETOF TEXT AS
> > '
> > DECLARE
> > r record;
> > BEGIN
> > FOR r IN
> > select router_name from router where router_name ~ $1
> > LOOP
> > RETURN NEXT r;
> > END LOOP;
> > RETURN;
> > END;
> > ' LANGUAGE 'plpgsql';
> 
> Close, but you want "RETURN NEXT r.router_name". r is a record
> potentially containing several fields, you have to say which you
> want.
> 
> regards, tom lane
> 
-- 
Thanks,
Nick
| From | Date | Subject | |
|---|---|---|---|
| Next Message | John DeSoi | 2005-05-31 23:15:49 | Re: Functions | 
| Previous Message | Tom Lane | 2005-05-31 18:47:21 | Re: Functions |