Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have function like this :

CREATE OR REPLACE FUNCTION f_insert_account(usernames character varying, passwds  
character varying, identitass integer, jeniss smallint, statuss smallint, cnames 
character varying, unames character varying)
RETURNS character varying AS
$BODY$
DECLARE
iduserx int4;
usernamex varchar;
er int2:=0;
pesan varchar:='';
BEGIN
insert into t_account(username,passwd,identitas,jenis,status,cname,uname)
values(usernamex,f_encr(passwds),identitass,jeniss,statuss,cnames,unames);
RETURN pesan;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION f_insert_account(usernames character varying, passwds character 
varying, identitass integer, jeniss smallint, statuss smallint, cnames character 
varying, unames character varying) OWNER TO postgres;

GRANT EXECUTE ON FUNCTION f_insert_account(usernames character varying, passwds 
character varying, identitass integer, jeniss smallint, statuss smallint, cnames  
character varying, unames character varying) TO public;

GRANT EXECUTE ON FUNCTION f_insert_account(usernames character varying, passwds 
character varying, identitass integer, jeniss smallint, statuss smallint, cnames   
character varying, unames character varying) TO postgres;

then I use that like this :

select f_insert_account('dayat', 'dayat', 1, 1, 1, 'cname', 'uname')

Error like this always appear : ERROR: function f_insert_account("unknown", "unknown", integer, integer, integer, "unknown", "unknown") does not exist SQL state: 42883 Hint: No function matches the given name and argument types. You may need to add explicit type casts. Character: 8

why is that ???

thanx,

Dayat

share|improve this question
1  
You show the creation of f_insert_account() and then complain about errors with f_account_sp(). Please clarify. –  Erwin Brandstetter Nov 17 '11 at 6:28

1 Answer 1

up vote 9 down vote accepted

The smallint datatype is a bit of a gotcha, since you need to cast these:

select f_insert_account('dayat', 'dayat', 1, 1::smallint, 1::smallint, 'cname', 'uname')

If you want to avoid this, I suggest changing your function definition to use plain old integer types.

share|improve this answer
    
Thanx Mike, it works. :) –  dayat Nov 17 '11 at 8:28
1  
+1, good catch. –  a_horse_with_no_name Nov 17 '11 at 9:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.