X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 5D6CD11F65C2 for ; Wed, 5 Apr 2006 13:27:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27774-02 for ; Wed, 5 Apr 2006 13:27:26 -0300 (ADT) X-Greylist: delayed 00:30:00.182294 by SQLgrey- Received: from smtpout.eastlink.ca (smtpout.eastlink.ca [24.222.0.30]) by postgresql.org (Postfix) with ESMTP id 4D28111F6ABE for ; Wed, 5 Apr 2006 13:27:11 -0300 (ADT) Received: from ip01.eastlink.ca ([24.222.10.5]) by mta01.eastlink.ca (Sun Java System Messaging Server 6.2-4.03 (built Sep 22 2005)) with ESMTP id <0IX900DCTAYWSX91@mta01.eastlink.ca> for pgsql-sql@postgresql.org; Wed, 05 Apr 2006 12:56:56 -0300 (ADT) Received: from blk-224-208-192.eastlink.ca (HELO tickletrunk.engtech.eng) ([24.224.208.192]) by ip01.eastlink.ca with ESMTP; Wed, 05 Apr 2006 12:57:12 -0300 Date: Wed, 05 Apr 2006 12:57:09 -0300 From: Michael Burke Subject: SELECT composite type To: pgsql-sql@postgresql.org Message-id: <200604051257.09980.michael@engtech.ca> Organization: Engineering Technologies Canada Ltd. MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline X-BrightmailFiltered: true X-Brightmail-Tracker: AAAAAQAAA+k= User-Agent: KMail/1.9.1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200604/19 X-Sequence-Number: 24828 Hello, I have a function get_xy that returns a composite type with columns "x" and "y". I would like to SELECT these as well as some data from a table, like so: SELECT (get_xy(SetSRID(sightings.location, 26910), 4326)).x, (get_xy(SetSRID(sightings.location, 26910), 4326)).y, sightings.title FROM sightings WHERE sighting_id = 25; This statement works, but I don't want to duplicate the function call as this should be unnecessary. Selecting simply get_xy returns both fields in a single column, which is undesirable. I tried: SELECT foo.x, foo.y, sightings.title FROM sightings, get_xy(SetSRID(sightings.location, 26910), 4326) foo WHERE sighting_id = 25; But, because the function refers to sightings, I get this error: ERROR: function expression in FROM may not refer to other relations of same query level ...which is reasonable. So I basically want to call get_xy for every row in sightings, and use its output for two columns; or perhaps there is another way to think of this. I am using Postgres 8.1.2 (same with client) on FreeBSD, with PostGIS 1.1.1: $ postmaster --version postmaster (PostgreSQL) 8.1.2 Thanks in advance! Mike. -- Michael Burke Engineering Technologies Canada Ltd. - http://www.engtech.ca/ michael@engtech.ca 1 (902) 628-1705