On 2014-04-02 12:27:30 -0400, Tom Lane wrote:
> David Johnston <pol...@yahoo.com> writes:
> > Does something like:
> > SELECT ($1 + $2)::$1%TYPE 
> > exist where you can explicitly cast to the type of the input argument?
> 
> I don't think SQL-language functions have such a notation, but it's
> possible in plpgsql, if memory serves.

Sometimes you can play nasty tricks using COALESCE() to force a cast
like that.
E.g. SELECT COALESCE(NULLIF($1, $1), $1 + $2);

Greetings,

Andres Freund

-- 
 Andres Freund                     http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to