pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedcalling user defined function with parameters..
2+ messages / 2 participants
[nested] [flat]
* calling user defined function with parameters..
@ 2001-06-16 12:56 Postgresql <frederes@free.fr>
2001-06-16 16:27 ` Re: calling user defined function with parameters.. Stephan Szabo <sszabo@megazone23.bigpanda.com>
0 siblings, 1 reply; 2+ messages in thread
From: Postgresql @ 2001-06-16 12:56 UTC (permalink / raw)
To: pgsql-sql
Hi,
I've created a function like this :
CREATE FUNCTION tester(INT4)
RETURNS BOOL AS
'
DECLARE
r RECORD;
p ALIAS FOR $1;
BEGIN
SELECT INTO r
id_dpt
FROM dpts
WHERE id_dpt=p;
IF NOT FOUND THEN
RETURN FALSE;
ELSE
RETURN TRUE;
END IF;
END;
'
LANGUAGE 'plpgsql';
All is ok at creation.
But now , how can i use my function ? i would like a thing like :
SELECT tester(14) AS ok;
But is make a Postgresql parser error
How to do then ??
Thanks for any help or links (other than the postgresql.org website...) !
;)
Regards,
Fred
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: calling user defined function with parameters..
2001-06-16 12:56 calling user defined function with parameters.. Postgresql <frederes@free.fr>
@ 2001-06-16 16:27 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
0 siblings, 0 replies; 2+ messages in thread
From: Stephan Szabo @ 2001-06-16 16:27 UTC (permalink / raw)
To: Postgresql <frederes@free.fr>; +Cc: pgsql-sql
What version are you using and what error are you getting? Your example
works for me on 7.2devel once i made a dpts table with an id_dpt column.
The function code is not checked for plpgsql until its first
use, so if there was a syntax error, it wouldn't be seen until you
tried to use it.
On Sat, 16 Jun 2001, Postgresql wrote:
> Hi,
>
> I've created a function like this :
>
> CREATE FUNCTION tester(INT4)
> RETURNS BOOL AS
> '
> DECLARE
> r RECORD;
> p ALIAS FOR $1;
>
> BEGIN
> SELECT INTO r
> id_dpt
> FROM dpts
> WHERE id_dpt=p;
>
> IF NOT FOUND THEN
> RETURN FALSE;
> ELSE
>
> RETURN TRUE;
> END IF;
> END;
> '
> LANGUAGE 'plpgsql';
>
> All is ok at creation.
> But now , how can i use my function ? i would like a thing like :
>
> SELECT tester(14) AS ok;
>
> But is make a Postgresql parser error
>
> How to do then ??
>
> Thanks for any help or links (other than the postgresql.org website...) !
>
> ;)
>
> Regards,
>
> Fred
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-06-16 16:27 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-16 12:56 calling user defined function with parameters.. Postgresql <frederes@free.fr>
2001-06-16 16:27 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox