Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id DFCE2DDB7D4 for ; Tue, 15 May 2012 03:25:47 -0300 (ADT) Received: from forward18.mail.yandex.net ([2a02:6b8:0:1402::3]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SUBCb-0004oy-OZ for pgsql-sql@postgresql.org; Tue, 15 May 2012 06:25:46 +0000 Received: from web21g.yandex.ru (web21g.yandex.ru [95.108.253.230]) by forward18.mail.yandex.net (Yandex) with ESMTP id A56B5178095A; Tue, 15 May 2012 10:25:29 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1337063129; bh=ai9fscz6CC6gnTwVZvPFeW8pRhiN8lwC0jwUiOpDzvs=; h=From:To:Cc:In-Reply-To:References:Subject:MIME-Version:Message-Id: Date:Content-Transfer-Encoding:Content-Type; b=P5Mm/X3LwBoHKNzQStmKGttfpSFY3UHpEAWwp439rbchxyzO1vvmfIBP2Ls2eV6uD WYpZTp+y52OhyC8jUQSNhBe9rbnAxORbm6ITZgt/ABghxBLXKDJHt7a9TaEBvNLurK jEgsW06bLTcbosOgjii9QWH0EVkHApBsFV4FNTD0= Received: from 127.0.0.1 (localhost.localdomain [127.0.0.1]) by web21g.yandex.ru (Yandex) with ESMTP id 653F07E0014; Tue, 15 May 2012 10:25:29 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1337063129; bh=ai9fscz6CC6gnTwVZvPFeW8pRhiN8lwC0jwUiOpDzvs=; h=From:To:Cc:In-Reply-To:References:Subject:MIME-Version:Message-Id: Date:Content-Transfer-Encoding:Content-Type; b=P5Mm/X3LwBoHKNzQStmKGttfpSFY3UHpEAWwp439rbchxyzO1vvmfIBP2Ls2eV6uD WYpZTp+y52OhyC8jUQSNhBe9rbnAxORbm6ITZgt/ABghxBLXKDJHt7a9TaEBvNLurK jEgsW06bLTcbosOgjii9QWH0EVkHApBsFV4FNTD0= Received: from [2.94.151.237] ([2.94.151.237]) by web21g.yandex.ru with HTTP; Tue, 15 May 2012 10:25:27 +0400 From: msi77 To: Jan Bakuwel Cc: "pgsql-sql@postgresql.org" In-Reply-To: <4FB1F13E.80302@greenpeace.org> References: <4FB1F13E.80302@greenpeace.org> Subject: Re: SELECT 1st field MIME-Version: 1.0 Message-Id: <498571337063127@web21g.yandex.ru> Date: Tue, 15 May 2012 10:25:27 +0400 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Pg-Spam-Score: -1.8 (-) X-Archive-Number: 201205/37 X-Sequence-Number: 36585 Try this create view v(id) as select * from func(5); if your function returns one column. 15.05.2012, 10:01, "Jan Bakuwel" : > Hi, > > I've spend some time checking the documentation but haven't been able to > find what I'm looking for. > I've got a function that returns a set of integers and a view that > selects from the function. > What I need is the ability to name the column in the view, ie. > > create function func(i int) returns setof integer as $$ > ... > ...code > ... > $$ language plpythonu volatile; > > create view v as select 1 as "id" from func(5); > > In other words I'd like to refer to the first (and only) field returned > and give that an alias, in this case "id". > > In some SQL dialects you can use "select 1" to select the first field, > "select 2" to select the 2nd field and so on. > > Any suggestions? > > regards, > Jan