pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John R Pierce <pierce@hogranch.com>
To: pgsql-bugs@postgresql.org
Subject: Re: how to proccess record returning null
Date: Fri, 14 Sep 2012 14:56:22 -0700
Message-ID: <5053A806.4060700@hogranch.com> (raw)
In-Reply-To: <1347636697274-5724061.post@n5.nabble.com>
References: <1347563825521-5723932.post@n5.nabble.com>
	<505265EA.7040901@hogranch.com>
	<1347636697274-5724061.post@n5.nabble.com>

On 09/14/12 8:31 AM, te wrote:
> Sorry I didnt mention it.
>
> temp is a table name.
>
> FOR r in select distinct(id) from temp
>
> There are no distinct id's in table 'temp', so record 'r' has null values.
>
> So I guess the control is not going inside the loop.
>
> Any suggestions?

there's a difference between zero records, and a record containing null 
fields..


yes, if there are no records, the loop will execute zero iterations, and 
result will be integer zero.

as coded, for each record, it will test if id is null or an empty 
string,   the result value will be that of the last distinct(id);

since no id is likely to be null or an empty string, the odds are, it 
will be returning 999 if there are any records and 0 if there aren't any.


what exactly do you WANT to do?



-- 
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast





view thread (5+ messages)  latest in thread

Message-ID: <5053A806.4060700@hogranch.com>
Permalink:  ../5053A806.4060700@hogranch.com/
Also on:    postgresql.org/message-id/5053A806.4060700@hogranch.com

 · 

reply

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: pierce@hogranch.com
  Subject: Re: how to proccess record returning null
  In-Reply-To: <5053A806.4060700@hogranch.com>
  References: <1347563825521-5723932.post@n5.nabble.com> <505265EA.7040901@hogranch.com> <1347636697274-5724061.post@n5.nabble.com> <5053A806.4060700@hogranch.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