Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 0341B6335F3 for ; Thu, 20 Aug 2009 12:35:29 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 92437-03 for ; Thu, 20 Aug 2009 15:35:19 +0000 (UTC) X-Greylist: delayed 00:14:22.629045 by SQLgrey-1.7.6 Received: from mail.fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by mail.postgresql.org (Postfix) with ESMTP id 2C044633A44 for ; Thu, 20 Aug 2009 12:35:19 -0300 (ADT) Received: from [157.92.155.58] (mailbis [157.92.155.58]) by mail.fmed.uba.ar (Postfix) with ESMTP id 99FB339C23B for ; Thu, 20 Aug 2009 12:19:55 -0300 (ART) Message-ID: <4A8D6912.60207@fmed.uba.ar> Date: Thu, 20 Aug 2009 12:17:38 -0300 From: Gerardo Herzig User-Agent: Thunderbird 2.0.0.6 (X11/20070801) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: using case to select 'which version to use' Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200908/112 X-Sequence-Number: 33021 Hi all. I have 2 functions , which returns the same columns, but with tottaly different logics. I want to wrap it with a third function, who will receive a boolean argument to decide wich sub-function have to use. I want to use case, so i dont have to use pl/pgsql. This is a non-working example: CREATE OR REPLACE FUNCTION get_oferta(varchar, varchar, varchar, bool, OUT cod varchar , OUT description varchar) returns setof record security definer as $$ select * from case $4 when true then (select * from get_oferta_from_a($1, $2, $3)) else (select * from get_oferta_from_b($1, $2, $3)) end; $$ language sql; Can i use case for a case like this? Thanks! Gerardo