pgplsql and parameters question

Started by Alex Sandiniover 23 years ago5 messagesgeneral
Jump to latest
#1Alex Sandini
asandini@keyware.com

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,

#2Alex Sandini
asandini@keyware.com
In reply to: Alex Sandini (#1)
Re: pgplsql and parameters question

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,

#3Gaetano Mendola
mendola@bigfoot.com
In reply to: Alex Sandini (#1)
Re: pgplsql and parameters question

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

#4Alex Sandini
asandini@keyware.com
In reply to: Alex Sandini (#1)
Re: pgplsql and parameters question

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

#5Gaetano Mendola
mendola@bigfoot.com
In reply to: Alex Sandini (#1)
Re: pgplsql and parameters question

"Alex Sandini" <asandini@keyware.com> wrote in message
news:3D7F5C34.1000809@keyware.com...

Please, dont't post useless messages
Alex

?? Was useless, this mean that is not problem of Postgres but your side
installation
problem.

Ciao
Gaetano.