Hi all,

I am new to postgresql and I am trying to write a function which uses record
(r) to select from table and then proccess that record value.

CREATE OR REPLACE FUNCTION clean()
  RETURNS integer AS $$
        DECLARE
        r record;
        result integer:= 0;
        BEGIN
        FOR r in select distinct(id) from temp 
        loop
                      IF r.id is null or r.id =''
                THEN result := 555;
                else result := 999;
                end if;
        end loop;  
        RETURN result;   
        END;
  $$ LANGUAGE plpgsql;


The problem here is 'r' is returning no records and I want to set result to
555 if r.id is null.
The function is created successfully but the result 

select clean()

is always '0'.

I am unable to spot the problem.

May be this is trivial but I am struggling for it.

Can anybody suggest anything?





--
View this message in context: 
http://postgresql.1045698.n5.nabble.com/how-to-proccess-record-returning-null-tp5723932.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to