Skip site navigation (1) Skip section navigation (2)

Re: Problem with FOR SELECT in plpgsql function

From: Richard Huxton <dev(at)archonet(dot)com>
To: Plant Thomas <Thomas(dot)Plant(at)lvh(dot)it>,"'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Problem with FOR SELECT in plpgsql function
Date: 2004-02-20 11:09:32
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On Friday 20 February 2004 10:07, Plant Thomas wrote:
> I have a problem with the following function:
> 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 
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

In response to

pgsql-sql by date

Next:From: Andrew SullivanDate: 2004-02-20 12:14:42
Subject: Re: pg_restore - don?t restore. Why?
Previous:From: Plant ThomasDate: 2004-02-20 10:07:22
Subject: Problem with FOR SELECT in plpgsql function

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group