From: | Max Ahston <max(at)ahston(dot)se> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Q: How do I return differnt rows depending on values |
Date: | 2004-03-20 07:35:54 |
Message-ID: | Pine.LNX.4.44.0403200834180.27242-100000@uplift.swm.pp.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> Couple problems that I can see. First, that test should be:
> IF $2 = ''tigris'' then
Thank you.
> Second, you'll need to add a "return;" line after the "END IF" for the
> cases where there is no match. In fact, you can just move the one from
> within the IF...END IF to outside it.
Ok, that explained an error I saw, but the function wasn't finished. This
is how the final result looks:
create or replace function get_dns2(varchar(40), varchar(40)) returns
setof holder as
'
declare
r holder%rowtype;
begin
IF ($2 = ''tigris'') then
for r in select \'Acc-Dns-Server-Pri\', op, value FROM radreply
where username = $1 and attribute =
\'Ascend-Client-Primary-DNS\' loop
return next r;
end loop;
for r in select \'Acc-Dns-Server-Sec\', op, value FROM radreply
where username = $1 and attribute =
\'Ascend-Client-Secondary-DNS\' loop
return next r;
end loop;
ELSE
for r in select Attribute, op, value FROM radreply
WHERE username = $1 loop
return next r;
end loop;
END IF;
return;
end
'
language 'plpgsql';
Thanks for the help!
Max!
From | Date | Subject | |
---|---|---|---|
Next Message | Francisco Reyes | 2004-03-20 09:45:06 | Re: Post to hacker list |
Previous Message | Steve Krall | 2004-03-20 06:13:55 | Re: pg_dump on older version of postgres eating huge |