Thread: Need help! parse erro

Need help! parse erro

From
Najm Hashmi
Date:
Hi every one, I  have just strated to use postgres. I wrote a vert
simple pl/pgsql function as given below:
CREATE FUNCTION
add_new_user(varchar(32),char(8),varchar(128),varchar(128),varchar(32),
varchar(32)) RETURNS boolean AS' DECLARE
oldUser RECORD;
USR ALIAS FOR $1;
PWORD ALIAS FOR $2;
EMAIL ALIAS FOR $3;
ADDR ALIAS FOR $4;
CITY ALIAS FOR $5;
CNTRY ALIAS FOR $6;
BEGIN
SELECT INTO oldUser *
FROM users
where username=USR AND password= PWORD;
IF FOUNDTHEN     RETURN ''f'';
ELSEINSERT INTO USERS(username,password,email,address,city,country)    values(USR,PWORD,EMAIL,ADDR,CITY,CNTRY);
RETURN''t'';
 
END IF;

END;'
LANGUAGE 'plpgsql';

When I run it  I get the following error:
najdb=# select

add_new_user('najm'::varchar,'najm1234'::char,'najmh@whatever'::varchar,'123street'::varchar,'mtl'::varchar,'canada'::varchar);

ERROR:  parser: parse error at or near "$1"
Someone, please help me out here.
I would also appreciate if you all "wizards" out there could send me
some more complex examples of plpgsql functions and triggers sinece
postgres docs doesn't have  any good ones. Thank you all for  all your
help.
Regards.
Najm.