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

Re: date bug

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jpat(at)mywayhealth(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: date bug
Date: 2001-05-16 22:59:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
"Jeff Patterson" <jpat(at)mywayhealth(dot)com> writes:
> Strange date behavior as shown below. 

This is not a date bug; it's your misunderstanding of how SQL functions
work.  A function that returns a scalar can only return one result, so
it makes no sense to try to define its result as a SELECT from a
multi-row table.

As it happens, what you get is the result from the first row returned
by the SELECT.  (Personally I'd have thought it'd make more sense to
raise an error if the SELECT returns multiple rows, but we'd probably
break existing applications if we changed it.)

Perhaps you want something on the order of

	SELECT EXISTS(SELECT 1 FROM holidays WHERE date = $1)

			regards, tom lane

In response to

  • date bug at 2001-05-15 01:33:32 from Jeff Patterson

pgsql-bugs by date

Next:From: Stephan SzaboDate: 2001-05-16 23:32:34
Subject: Re: orphaned trigger
Previous:From: Jonathan EllisDate: 2001-05-16 22:57:34
Subject: Re: orphaned trigger

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