pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Plant Thomas <Thomas.Plant@lvh.it>
To: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: Re: Problem with FOR SELECT in plpgsql function
Date: Fri, 20 Feb 2004 11:09:32 +0000
Message-ID: <200402201109.32849.dev@archonet.com> (raw)
In-Reply-To: <418DEFFAA399D311818A00508B912F2801A9F748@idefix.lvh.dnet.it>
References: <418DEFFAA399D311818A00508B912F2801A9F748@idefix.lvh.dnet.it>

On Friday 20 February 2004 10:07, Plant Thomas wrote:
> I have a problem with the following function:
[snip]
>
> This function sometimes returns null even if there is a record in the
> database for the corrisponding id.
> This happens only when there is only one record for the corrisponding id
> value in the database, if there
> are more than one record it works with no problem.

If it actually returns NULL and not the empty string, then the loop must be 
processed, since you set "uhrzeiten" to the empty string before the loop.

Two things to check:
1. None of your variables match a column in your select (and you seem OK 
here).
2. None of the fields in your expression are null (e.g. dat.vormittag_a)

I think it's #2 - concat NULL to any string and you get NULL back.


-- 
  Richard Huxton
  Archonet Ltd



view thread (2+ messages)

Message-ID: <200402201109.32849.dev@archonet.com>
Permalink:  ../200402201109.32849.dev@archonet.com/
Also on:    postgresql.org/message-id/200402201109.32849.dev@archonet.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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, Thomas.Plant@lvh.it
  Subject: Re: Problem with FOR SELECT in plpgsql function
  In-Reply-To: <200402201109.32849.dev@archonet.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