From: | te <tejal_1910(at)yahoo(dot)co(dot)in> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | how to proccess record returning null |
Date: | 2012-09-13 19:17:05 |
Message-ID: | 1347563825521-5723932.post@n5.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Page | 2012-09-13 20:17:19 | Re: initdb.exe changes --locale option |
Previous Message | Marko Tiikkaja | 2012-09-13 18:46:00 | Re: BUG #7516: PL/Perl crash |