I am very new to postgres. I got this error when try to run the following script:
CREATE OR REPLACE FUNCTION xyz(text) RETURNS INTEGER AS
'DECLARE result int;
BEGIN
SELECT count(*) into result from tbldealercommissions
WHERE
txtdealercode = $1;
if result < 1 then returns 1;
else returns 2 ;
end if;
END;
'
LANGUAGE sql VOLATILE;
The error is
ERROR: syntax error at or near "int"
LINE 3: 'DECLARE result int;
not sure what cause this error. Any help is appreciated.