Re: Semi-Pseudo Data Types & Procedure Arguments - Mailing list pgsql-general

From Karsten Hilbert
Subject Re: Semi-Pseudo Data Types & Procedure Arguments
Date
Msg-id 20130626151809.GA4024@hermes.hilbert.loc
Whole thread Raw
In response to Semi-Pseudo Data Types & Procedure Arguments  (Joshua Burns <jdburnz@gmail.com>)
List pgsql-general
On Wed, Jun 26, 2013 at 01:50:46AM -0400, Joshua Burns wrote:

> Example #1:
> -- A stored procedure which can accept two arguments, each of which could
> be text, character varying, character varying(any length) or character(any
> length).
> SELECT * FROM my_fn('val1'::text, 'val2'::character(4));
>
> Example #2:
> -- A stored procedure which can accept two arguments, each of which could
> be smallint, integer, or bigint.
> SELECT * FROM my_fn('1'::smallint, '3726323626326262362'::bigint);

...

> In regards to Examples 1 & 2, I'm at a complete loss.

I suppose you can use function overloading.

Have only the "base" function (that which operates on the
"largest" type, say TEXT/BIGINT) contain the actual code and
write wrappers in the SQL PL (not plpgsql) which accept
other types and cast towards TEXT and BIGINT as needed.

Karsten
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: utf8 errors
Next
From: Rory Campbell-Lange
Date:
Subject: Re: array_agg and partition sorts