Re: Functions just dont want to work! [hard]

From: Joel Burton <joel(at)joelburton(dot)com>
To: Yonatan Ben-Nes <da(at)canaan(dot)co(dot)il>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Functions just dont want to work! [hard]
Date: 2002-12-04 19:53:43
Message-ID: 20021204195343.GA18499@temp.joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Dec 04, 2002 at 08:32:34PM +0200, Yonatan Ben-Nes wrote:
> Hi,
>
> I'm having a problem at a code which worked already and now after installing the new postgresql version it doesn't work (i didnt check it actually for about 2-3 months but i didnt change anything in the meanwhile).
>
> the problem occur only with functions which i created and the error which it gives me is (all of the functions get the same error) -
> Warning: PostgreSQL query failed: ERROR: Function insert_new_field(integer, "unknown", "unknown") does not exist Unable to identify a function that satisfies the given argument types You may need to add explicit typecasts.
>
> now i echoed the sql line itself and its -
> SELECT insert_new_field(24, '2', '2');
>
> while the function code itself is -
>
> CREATE FUNCTION public.insert_new_field(int2, text, text) RETURNS text AS '

Problem is that 24 is not an int2 -- it's an int4 (generic int type).
For example:

joel(at)joel=# create function hi(int2) returns bool as 'begin return true;
end;' language 'plpgsql';
CREATE FUNCTION
joel(at)joel=# select hi(42);
ERROR: Function hi(integer) does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts

select hi(42::int2);

works just fine.

Either add a function that takes int4,tedt,text input, or explicitly
cast your int4 to int2, as show above.
--

Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Independent Knowledge Management Consultant

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Naeslund(f) 2002-12-04 19:56:12 Re: Postgresql -- initial impressions and comments
Previous Message Kris Jurka 2002-12-04 19:50:24 Re: JDBC driver - first impressions and comments