Re: postgresql function not accepting null values inselect statement - Mailing list pgsql-sql

From Jyoti Seth
Subject Re: postgresql function not accepting null values inselect statement
Date
Msg-id 002401c8776e$17698b80$463ca280$@com
Whole thread Raw
In response to Re: postgresql function not accepting null values inselect statement  (johnf <jfabiani@yolo.com>)
Responses Re: postgresql function not accepting null valuesinselect statement
List pgsql-sql
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@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]
On Behalf Of johnf
Sent: Friday, February 22, 2008 10:01 PM
To: pgsql-sql@postgresql.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



pgsql-sql by date:

Previous
From: Aarni Ruuhimäki
Date:
Subject: Re: SQL standards in Mysql
Next
From: Stuart Brooks
Date:
Subject: autovacuum not freeing up unused space on 8.3.0