Search Postgresql Archives

Re: Semi-Pseudo Data Types & Procedure Arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux