Re: ERROR: query returned no rows

From: Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: query returned no rows
Date: 2017-06-26 19:03:30
Message-ID: c4d97388-fb6a-5ebf-6cc2-ec344617c7f6@illuminatedcomputing.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 06/26/2017 11:21 AM, Alexander Farber wrote:
> The error message returned by
> the database is rather cryptic:
>
> words=> select * from words_skip_game(1, 1);
> ERROR: query returned no rows
> CONTEXT: PL/pgSQL function words_skip_game(integer,integer) line 85 at
> SQL statement
>
> When I look at my source code
> ( https://gist.github.com/afarber/cac9a83b7a37307ace8d787be9b8ff4c ) at
> the line 85, then I am not sure if the line number reported by the error
> message is correct, because it points into middle of an UPDATE statement:

I agree the line numbers for error messages inside of plpgsql functions
never seem to make sense, so I wouldn't get too hung up on line 85.
Perhaps you should see what is line 85 when you do `\sf words_skip_game`
(rather than line 85 in your own source code). But mostly I would try to
find some other way of locating the cause of the error.

You can read about the "query returned no rows" message here:

https://www.postgresql.org/docs/9.5/static/plpgsql-statements.html

It seems to me you should only see it for `INTO STRICT`, not plain
`INTO`. I see from your gist that your function *does* have some queries
that are `INTO STRICT`, so I would focus on those.

That page also describes how to use `print_strict_params` to get a
little more info about the details of the error.

I hope that helps!

Paul

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2017-06-26 19:47:38 Re: ERROR: query returned no rows
Previous Message Alexander Farber 2017-06-26 18:57:28 Re: ERROR: query returned no rows