Function overloading

From: Rynell Wesson <rwesson(at)cs(dot)utexas(dot)edu>
To: pgsql-novice(at)postgresql(dot)org
Subject: Function overloading
Date: 2000-12-10 03:42:56
Message-ID: Pine.LNX.4.21.0012092142180.30190-100000@isle-of-jura.cs.utexas.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2000-12-10 04:15:30 Re: Function overloading
Previous Message Nabil Sayegh 2000-12-10 02:04:30 Re: [BUGS] 7.1beta1 JDBC Nested cursor problem