From: | "Bart Degryse" <Bart(dot)Degryse(at)indicator(dot)be> |
---|---|
To: | "Jyoti Seth" <jyotiseth2001(at)gmail(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: postgresql function not accepting null valuesinselect statement |
Date: | 2008-02-25 08:05:07 |
Message-ID: | 47C284BF.A3DD.0030.0@indicator.be |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
In the documentation "IS NOT DISTINCT FROM" only appears in version 8.2
The 8.0 and 8.1 documentation only mentions "IS DISTINCT FROM".
http://www.postgresql.org/docs/8.2/static/functions-comparisons.html
http://www.postgresql.org/docs/8.1/static/functions-comparisons.html
http://www.postgresql.org/docs/8.0/static/functions-comparisons.html
I haven't tried it, but probably replacing
WHERE f.statecd IS NOT DISTINCT FROM p_statecd)
with
WHERE not(f.statecd IS DISTINCT FROM p_statecd))
will do the same.
>>> "Jyoti Seth" <jyotiseth2001(at)gmail(dot)com> 2008-02-25 6:20 >>>
I have tried this, but it is showing following error:
ERROR: syntax error at or near "DISTINCT"
SQL state: 42601
Thanks,
Jyoti
-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-owner(at)postgresql(dot)org]
On Behalf Of johnf
Sent: Friday, February 22, 2008 10:01 PM
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] postgresql function not accepting null values inselect
statement
On Friday 22 February 2008 01:35:47 am Bart Degryse wrote:
> Can you try this...
>
> CREATE OR REPLACE FUNCTION getfunctionaries(p_statecd integer)
> RETURNS SETOF t_functionaries AS
> $BODY$
> DECLARE
> rec t_functionaries%ROWTYPE;
> BEGIN
> FOR rec IN (
> SELECT f.functionaryid, f.category, f.description
> FROM functionaries f
> WHERE f.statecd IS NOT DISTINCT FROM p_statecd)
> LOOP
> return next rec;
> END LOOP;
> return;
> END;
> $BODY$
> LANGUAGE 'plpgsql' VOLATILE;
>
a newbie question. Could you explain why yours works? I don't understand
how
it works if p_statecd = NULL
--
John Fabiani
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org ( http://archives.postgresql.org/ )
From | Date | Subject | |
---|---|---|---|
Next Message | Dean Gibson (DB Administrator) | 2008-02-25 21:08:07 | Re: Bouncing replies [was: SQL standards in Mysql] |
Previous Message | Robins Tharakan | 2008-02-25 07:03:08 | Re: postgresql function not accepting null values inselect statement |