Thread: Problem with function, type cast?

Problem with function, type cast?

From
"A B"
Date:
I have written this little silly function

CREATE OR REPLACE FUNCTION recordMail(customerId_ integer, message_
VARCHAR(240)) RETURNS void AS $$
BEGIN
       INSERT INTO MailRecord (custid,message) VALUES (customerId_, message_);
END;
$$ LANGUAGE plpgsql;

And it is created, and then I do:

select recordMail(10,'asd');

and I get


ERROR:  function recordmail(integer, "unknown") does not exist
LINE 1: select recordMail(10,'asd');
              ^
HINT:  No function matches the given name and argument types. You may
need to add explicit type casts.



Isn't postgresql supposed to be able to convert it to a suitable
datatype and find the matching function?

Re: Problem with function, type cast?

From
"A. Kretschmer"
Date:
am  Thu, dem 15.05.2008, um 16:47:33 +0200 mailte A B folgendes:
> I have written this little silly function
>
> CREATE OR REPLACE FUNCTION recordMail(customerId_ integer, message_
> VARCHAR(240)) RETURNS void AS $$
> BEGIN
>        INSERT INTO MailRecord (custid,message) VALUES (customerId_, message_);
> END;
> $$ LANGUAGE plpgsql;
>
> And it is created, and then I do:
>
> select recordMail(10,'asd');
>
> and I get
>
>
> ERROR:  function recordmail(integer, "unknown") does not exist
> LINE 1: select recordMail(10,'asd');

Sorry, but i can't reproduce this error:

test=# create table mailrecord (custid int, message text);
CREATE TABLE
test=*# CREATE OR REPLACE FUNCTION recordMail(customerId_ integer, message_
test(# VARCHAR(240)) RETURNS void AS $$
test$# BEGIN
test$#        INSERT INTO MailRecord (custid,message) VALUES (customerId_, message_);
test$# END;
test$# $$ LANGUAGE plpgsql;
CREATE FUNCTION
test=*# select recordMail(10,'asd');
 recordmail
------------

(1 row)

test=*#


Which version do you have? I have 8.1.

Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net