From: te <tejal_1910@yahoo.co.in>
To: pgsql-bugs@postgresql.org
Subject: how to proccess record returning null
Date: Thu, 13 Sep 2012 12:17:05 -0700 (PDT)
Message-ID: <1347563825521-5723932.post@n5.nabble.com> (raw)
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tejal_1910@yahoo.co.in
Subject: Re: how to proccess record returning null
In-Reply-To: <1347563825521-5723932.post@n5.nabble.com>
References: <1347563825521-5723932.post@n5.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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