RETURN QUERY SELECT & TYPE

From: screamge <screamge(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: RETURN QUERY SELECT & TYPE
Date: 2010-08-10 05:00:56
Message-ID: AANLkTi=Yh3AVFk-BSszTZ9yGGcxfx89_wG6O-rswkkwo@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Here is code of first procedure:

CREATE TYPE some_item AS
(id integer,
title character varying,
...
);

CREATE OR REPLACE FUNCTION some_func (integer) RETURNS some_item AS
...
itemid ALIAS for $1;
resulter some_item%rowtype;

...
SELECT INTO resulter
n_id, t_title FROM some_table WHERE n_id = itemid;
RETURN resulter;

I want to call some_func from another procedure and get result set of
some_items type. Something like this:

CREATE OR REPLACE FUNCTION other_func (integer) RETURNS SETOF some_item AS
...
RETURN QUERY SELECT some_func(id) FROM another_table;
;

But when i run other_func i get:

ERROR: structure of query does not match function result type

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sim Zacks 2010-08-10 05:42:05 Re: pgtune
Previous Message Scott Marlowe 2010-08-10 03:56:05 Re: Win Server 2003: postgres can't logon