using case to select 'which version to use' - Mailing list pgsql-sql

From Gerardo Herzig
Subject using case to select 'which version to use'
Date
Msg-id 4A8D6912.60207@fmed.uba.ar
Whole thread Raw
Responses Re: using case to select 'which version to use'  (Rodrigo E. De León Plicet <rdeleonp@gmail.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: George Woodring
Date:
Subject: Advice returning data as an array
Next
From: Rodrigo E. De León Plicet
Date:
Subject: Re: using case to select 'which version to use'