Re: Q: How do I return differnt rows depending on values
От | Max Ahston |
---|---|
Тема | Re: Q: How do I return differnt rows depending on values |
Дата | |
Msg-id | Pine.LNX.4.44.0403200834180.27242-100000@uplift.swm.pp.se обсуждение исходный текст |
Ответ на | Re: Q: How do I return differnt rows depending on values (Joe Conway <mail@joeconway.com>) |
Список | 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!
В списке pgsql-general по дате отправления: