Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 775E0B5DBE0 for ; Tue, 21 Jun 2011 00:57:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 19580-02 for ; Tue, 21 Jun 2011 03:57:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iy0-f174.google.com (mail-iy0-f174.google.com [209.85.210.174]) by mail.postgresql.org (Postfix) with ESMTP id 21366B5DBDD for ; Tue, 21 Jun 2011 00:57:07 -0300 (ADT) Received: by iyb12 with SMTP id 12so2531226iyb.19 for ; Mon, 20 Jun 2011 20:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=JjkEZpVELAk3k+YYsViuegnL056lceGFmUDJKUyXiCk=; b=BaPS2MwjEHBO/vuft3YaZSJHNNEt6FmfPqomNyesDOxXFzZxMTycR4ojrlZFwqKcTF A4Hzkzgj8CNt/GZ+rxAVj6MJ6UZ/L1WXN2Lj0qOuv1CJY/j/gAVla32UuULOhY0n0cw1 5g+8YZeB6N3fgOVQpjOJhdnvkLZe3fg4pL/xk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=IZF4dpPfklp0w+EQLCItahuJePzl+b1nC3fcxBzqexHtyatGhFKGgPUXopkCTXUEle JfAqXUtdO+YIVOY87t4k/a5fQJTTUs/iq7ep5s/Ixot8xnVMToaTLbaWQcLtr77qvCtW Xw+oM6TQjJy3FSkFnurM1+7EMzd3/N5104yLs= Received: by 10.42.156.67 with SMTP id y3mr7104172icw.133.1308628626072; Mon, 20 Jun 2011 20:57:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.42.1.141 with HTTP; Mon, 20 Jun 2011 20:56:26 -0700 (PDT) In-Reply-To: <4DFFFA26.6010003@gmx.net> References: <4DFFFA26.6010003@gmx.net> From: Pavel Stehule Date: Tue, 21 Jun 2011 05:56:26 +0200 Message-ID: Subject: Re: problem with selecting from a function To: Andreas Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201106/73 X-Sequence-Number: 35539 2011/6/21 Andreas : > Hi, > > I've got a table with a couple of objects. > Primary key object_id. > > There is a function that fetches some values from another table that rela= te > to an object_id. > Like =C2=A0 fctX ( 7 ) =C2=A0--> set of typX ... ( 14, 'bla' ), ( 17, 'bl= u' ), ( 21, > 'ble' ), ... > The result of the function can have 0 or more lines of a defined result-t= ype > typX. > Those resulting numbers are not object_ids. > > Now I'd need a SELECT that lists all function results of all object_ids. > Like: > ... > 6, ... > 7, 14, 'bla' > 7, 17, 'blu' > 7, 21, 'ble' > 8, ... > > Actually it was enough to get just the numerical column of the function > result. > > I tried > select object_id, fctX (object_id) from objects; > Then I get: > 7, (14, 'bla') > 7, (17, 'blu') > 7, (21, 'ble') <--- round brackets > This looks like an array but how can I split it up to columns or at least > extract the number-column? > this is composite value you can try SELECT object_id, (fctX(object_id)).* from objects Regards Pavel Stehule > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql >