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

Re: BUG #5105: "Select Into Strict" does not throw NO_DATA_FOUND

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <pgsql-bugs(at)postgresql(dot)org>,"Walter Mesz" <meszwalter(at)yahoo(dot)de>
Subject: Re: BUG #5105: "Select Into Strict" does not throw NO_DATA_FOUND
Date: 2009-10-08 15:28:51
Message-ID: 4ACDBEE3020000250002B73F@gw.wicourts.gov (view raw or flat)
Thread:
Lists: pgsql-bugs
"Walter Mesz" <meszwalter(at)yahoo(dot)de> wrote:
 
> my problem is that this select into does not throw a NO_DATA_FOUND
> if my select involves a max(). I did not see this behaviour
> documented anywhere and could not find it in a reasonable time at
> google.
 
>  SELECT max(tanum)
>            INTO STRICT x
>            FROM lo_prod_req
>           WHERE tanum = '1234567';
 
The documentation says:
 
$ If the STRICT option is specified, the query must return exactly one
$ row or a run-time error will be reported
 
http://www.postgresql.org/docs/8.3/interactive/plpgsql-statements.html
 
In this case the query will always return one row.  The row may have a
NULL if no matching values were found, but the row will be there.
 
select max(x) from (select generate_series(1,10) as x) y where x > 10;
 max
-----

(1 row)
 
Not a bug.
 
-Kevin

In response to

pgsql-bugs by date

Next:From: Dominic BevacquaDate: 2009-10-08 15:29:51
Subject: incorrect exit code from psql with single transaction + violation of deferred FK constraint
Previous:From: Tom LaneDate: 2009-10-08 15:22:42
Subject: Re: BUG #5105: "Select Into Strict" does not throw NO_DATA_FOUND

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