Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 5B836930E1E for ; Fri, 3 Aug 2012 05:37:25 -0300 (ADT) Received: from 10610.x.rootbsd.net ([204.109.60.69] helo=vps001.shopzeus.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SxDNs-0006O0-Qy for pgsql-admin@postgresql.org; Fri, 03 Aug 2012 08:37:25 +0000 Received: from [192.168.1.105] (localhost [127.0.0.1]) by vps001.shopzeus.com (8.14.3/8.14.3) with ESMTP id q738bEL0056037 for ; Fri, 3 Aug 2012 04:37:15 -0400 (EDT) (envelope-from gandalf@shopzeus.com) Message-ID: <501B8DB7.5050700@shopzeus.com> Date: Fri, 03 Aug 2012 10:37:11 +0200 From: Laszlo Nagy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: need help to write a function in postgresql References: <000b01cd658e$e66ae920$b340bb60$@avineonindia.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/16 X-Sequence-Number: 39837 > Then you can do: > select * > from retrieve_user('foo', 'bar'); > > Personally I'd prefer to create view that wraps that select statement > and then simply do a > > select * > from user_view > where name = 'foo' > and password = 'bar' It is also better because with a view, you can also do " name is null ". But you cannot do that with a function (unless you write unnecessary circumstancial code.)