pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedpassing null parameter to plpgsq functions
4+ messages / 2 participants
[nested] [flat]
* passing null parameter to plpgsq functions
@ 2001-04-03 07:00 Picard, Cyril <cyril.picard@eads-dsn.com>
0 siblings, 1 reply; 4+ messages in thread
From: Picard, Cyril @ 2001-04-03 07:00 UTC (permalink / raw)
To: pgsql-sql
Hello
I wrote a plpgsql function with few parameters ; when I call the function,
some of the parameters can be null.
In this case, all the parameters are considered as null in the function's
body ! is it a feature ? how can I work around this ?
Example :
CREATE FUNCTION foo(text, text) RETURNS bool AS '
begin
IF ($1 IS NULL) AND ($2 IS NULL) THEN
RETURN FALSE;
ELSE
RETURN TRUE;
END IF;
end;
' LANGUAGE 'plpgsql';
SELECT foo(null,'bouh') => false (I expected true)
SELECT foo('schfk',null) => false (I expected true)
SELECT foo(null,null) => false (OK)
SELECT foo('schfk','bouh') => true (OK)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: passing null parameter to plpgsq functions
@ 2001-04-03 08:05 Richard Huxton <dev@archonet.com>
parent: Picard, Cyril <cyril.picard@eads-dsn.com>
0 siblings, 0 replies; 4+ messages in thread
From: Richard Huxton @ 2001-04-03 08:05 UTC (permalink / raw)
To: Picard, Cyril <cyril.picard@eads-dsn.com>; pgsql-sql
From: "Picard, Cyril" <cyril.picard@eads-dsn.com>
> Hello
> I wrote a plpgsql function with few parameters ; when I call the function,
> some of the parameters can be null.
> In this case, all the parameters are considered as null in the function's
> body ! is it a feature ? how can I work around this ?
It's a feature in versions before 7.1 (or possibly 7.0.x) you can still get
that behaviour in 7.1 by asking for strict null handling on a specific
function.
The only remedy AFAIK is to upgrade.
- Richard Huxton
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: passing null parameter to plpgsq functions
@ 2001-04-03 09:39 Picard, Cyril <cyril.picard@eads-dsn.com>
0 siblings, 1 reply; 4+ messages in thread
From: Picard, Cyril @ 2001-04-03 09:39 UTC (permalink / raw)
To: pgsql-sql
Thank you ! I planned to use the 7.1 to get the outer join capability.
Is the 7.1 stable ?
> -----Message d'origine-----
> De: Richard Huxton [SMTP:dev@archonet.com]
> Date: mardi 3 avril 2001 10:06
> À: Picard, Cyril; pgsql-sql@postgresql.org
> Objet: Re: [SQL] passing null parameter to plpgsq functions
>
> From: "Picard, Cyril" <cyril.picard@eads-dsn.com>
>
> > Hello
> > I wrote a plpgsql function with few parameters ; when I call the
> function,
> > some of the parameters can be null.
> > In this case, all the parameters are considered as null in the
> function's
> > body ! is it a feature ? how can I work around this ?
>
> It's a feature in versions before 7.1 (or possibly 7.0.x) you can still
> get
> that behaviour in 7.1 by asking for strict null handling on a specific
> function.
>
> The only remedy AFAIK is to upgrade.
>
> - Richard Huxton
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: passing null parameter to plpgsq functions
@ 2001-04-03 11:51 Richard Huxton <dev@archonet.com>
parent: Picard, Cyril <cyril.picard@eads-dsn.com>
0 siblings, 0 replies; 4+ messages in thread
From: Richard Huxton @ 2001-04-03 11:51 UTC (permalink / raw)
To: Picard, Cyril <cyril.picard@eads-dsn.com>; pgsql-sql
From: "Picard, Cyril" <cyril.picard@eads-dsn.com>
> Thank you ! I planned to use the 7.1 to get the outer join capability.
>
> Is the 7.1 stable ?
Pretty much - it's reached release candidate stage and I've been using it
for development for a while now.
- Richard Huxton
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2001-04-03 11:51 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-04-03 07:00 passing null parameter to plpgsq functions Picard, Cyril <cyril.picard@eads-dsn.com>
2001-04-03 08:05 ` Richard Huxton <dev@archonet.com>
2001-04-03 09:39 RE: passing null parameter to plpgsq functions Picard, Cyril <cyril.picard@eads-dsn.com>
2001-04-03 11:51 ` Richard Huxton <dev@archonet.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