Function overloading

Поиск
Список
Период
Сортировка
От Rynell Wesson
Тема Function overloading
Дата
Msg-id Pine.LNX.4.21.0012092142180.30190-100000@isle-of-jura.cs.utexas.edu
обсуждение исходный текст
Ответы Re: Function overloading  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
I have tried to overload a function with the following signatures.

CREATE FUNCTION foo(int4, int4)
  RETURNS NUMERIC AS '

CREATE FUNCTION foo(text, text)
  RETURNS NUMERIC AS '

Can someone please tell me how to make these overloaded functions work
at the same time?  I keep getting the following error.

psql:fdm:11: ERROR:  Function 'foo(unknown, unknown)' does not exist
   Unable to identify a function that satisfies the given argument types
   You may need to add explicit typecasts

The foo(text, text) works just fine alone when I do not compile/store the
foo(int4, int4) procedure in the database together with it.  The
foo(int4, int4) procedure works regardless of whether I compile/store the
foo(text, text) procedure together with it in the database.  The error
message seems to be complaining about the foo(text, text) procedure.  I
have tried the following typecasts and format conversions to see if it
would accept it, but still with no success.  Maybe I am casting the
types incorrectly.  Can someone help me out?

select foo((text) 'testing', (text) 'testing');
select foo((varchar) 'testing', (varchar) 'testing');
select foo(text('testing'), text('testing'));
select foo(varchar('testing'), varchar('testing'));
... and others that did not work....

Here is the output of \df foo

        List of functions
 Result  | Function | Arguments
---------+----------+------------
 numeric | foo      | int4 int4
 numeric | foo      | text text
(2 rows)

Additional info:

Operating System:  Linux 2.2.16 #1 SMP i686
Postgres version:  7.0.2

Thanks.

Rynell Wesson




В списке pgsql-novice по дате отправления:

Предыдущее
От: Nabil Sayegh
Дата:
Сообщение: Re: [BUGS] 7.1beta1 JDBC Nested cursor problem
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Function overloading