pgplsql and parameters question
I don't get parameters working in my pgplsql functions.
I.e.:
CREATE FUNCTION add_one (INTEGER) RETURNS INTEGER AS '
BEGIN
RETURN ($1 + 1);
END;
' LANGUAGE 'plpgsql';
Does not work's for me, while the following one works just fine.
CREATE FUNCTION startweek() RETURNS DATE AS '
DECLARE
start date;
BEGIN
start:= to_date(''01-01-''||date_part(''year'', timestamp ''now''),''DD
MM YYYY'') + date_part(''week'', timestamp ''now'') * 7 - 8;
RETURN start;
END;
' LANGUAGE 'plpgsql';
Any idea?
Thanks,
Sorry, error message is (for function add_one):
ERROR: Unable to identify left operator '+' for type 'int4'
You may need to add parentheses or an explicit cast
Alex Sandini wrote:
Show quoted text
I don't get parameters working in my pgplsql functions.
I.e.:CREATE FUNCTION add_one (INTEGER) RETURNS INTEGER AS '
BEGIN
RETURN ($1 + 1);
END;
' LANGUAGE 'plpgsql';Does not work's for me, while the following one works just fine.
CREATE FUNCTION startweek() RETURNS DATE AS '
DECLARE
start date;
BEGIN
start:= to_date(''01-01-''||date_part(''year'', timestamp ''now''),''DD
MM YYYY'') + date_part(''week'', timestamp ''now'') * 7 - 8;
RETURN start;
END;
' LANGUAGE 'plpgsql';Any idea?
Thanks,
Alex Sandini wrote:
I don't get parameters working in my pgplsql functions.
I.e.:CREATE FUNCTION add_one (INTEGER) RETURNS INTEGER AS '
BEGIN
RETURN ($1 + 1);
END;
' LANGUAGE 'plpgsql';Does not work's for me, while the following one works just fine.
I tried this on:
Postgres 7.1.3
and Postgres 7.2.2 without problems.
Ciao
Gaetano
Please, dont't post useless messages
Alex
Gaetano Mendola wrote:
Show quoted text
Alex Sandini wrote:
I don't get parameters working in my pgplsql functions.
I.e.:CREATE FUNCTION add_one (INTEGER) RETURNS INTEGER AS '
BEGIN
RETURN ($1 + 1);
END;
' LANGUAGE 'plpgsql';Does not work's for me, while the following one works just fine.
I tried this on:
Postgres 7.1.3
and Postgres 7.2.2 without problems.Ciao
Gaetano