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

Re: [SQL] plpgsql question

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Postgres Admin <postgres(at)productivitymedia(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org,PostgreSQL - Admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: [SQL] plpgsql question
Date: 2005-08-31 02:32:49
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-adminpgsql-sql
On Tue, Aug 30, 2005 at 01:59:04PM -0400, Postgres Admin wrote:
> ERROR:  set-valued function called in context that cannot accept a set
> CONTEXT:  PL/pgSQL function "article_sample" line 10 at return next

You don't show what you did to get this error, but I'd guess you
called the function like this:

  SELECT article_display(10, 0);  -- wrong

You should have called it like this:

  SELECT * FROM article_display(10, 0);

The function as posted has a few other problems, like returning the
wrong type (you return a RECORD variable instead of an article_output
variable) and not selecting enough columns for the declared return
type.  The return type also doesn't match the type shown in the
CREATE TYPE statement, and the CREATE TYPE statement fails with a
syntax error due to a missing comma.  As I mentioned previously,
please post the *exact* code you're running so typographic errors
in the message don't distract from the real problem.  Those typos
prevent people from loading the code into their own database so
they can test it unless they correct the mistakes, and then they
can't be sure they're running the same thing you are.

Michael Fuhr

In response to

pgsql-admin by date

Next:From: Ben MitchellDate: 2005-08-31 03:41:07
Subject: Backup / Restore help
Previous:From: Marko KreenDate: 2005-08-31 00:59:51
Subject: Re: Location of pgpass.conf File

pgsql-sql by date

Next:From: Joost KraaijeveldDate: 2005-08-31 10:00:30
Subject: How do I copy part of table from db1 to db2 (and rename thecolumns)?
Previous:From: andy rostDate: 2005-08-30 20:10:21
Subject: Re: sqlstate 02000 while declaring cursor/freeing prepared

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