![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
From: Tom Lane <tgl (AT) sss (DOT) pgh.pa.us To: "Gerard Mason" <gerardmason (AT) hotmail (DOT) com CC: pgsql-novice (AT) postgresql (DOT) org Subject: Re: [NOVICE] Returning arbitrary row sets from a function Date: Tue, 16 Dec 2003 09:28:04 -0500 Received: from mc5-f1.hotmail.com ([65.54.252.8]) by mc5-s6.hotmail.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 16 Dec 2003 06:33:44 -0800 Received: from noon.pghoster.com ([64.246.0.64]) by mc5-f1.hotmail.com with Microsoft SMTPSVC(5.0.2195.6824); Tue, 16 Dec 2003 06:33:43 -0800 Received: from svr1.postgresql.org ([200.46.204.71] helo=postgresql.org)by noon.pghoster.com with esmtp (Exim 4.24)id 1AWGCE-00055p-BQ; Tue, 16 Dec 2003 08:29:10 -0600 Received: from localhost (neptune.hub.org [200.46.204.2])by svr1.postgresql.org (Postfix) with ESMTP id 5D1F5D1DBD0for pgsql-novice-postgresql.org (AT) loc...postgresql.org>; Tue, 16 Dec 2003 14:28:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 43887-04 for <pgsql-novice-postgresql.org (AT) localhost (DOT) postgresql.org>; Tue, 16 Dec 2003 10:28:05 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242])by svr1.postgresql.org (Postfix) with ESMTP id 8C331D1DC11for pgsql-novice (AT) postgresql (DOT) org>; Tue, 16 Dec 2003 10:28:01 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1])by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBGES419021036;Tue, 16 Dec 2003 09:28:04 -0500 (EST) X-Message-Info: pdGgd64CkwbpMDe6De87M4BVeULv8cLfHTWRrON5Om0= X-Original-To: pgsql-novice-postgresql.org (AT) loc...postgresql.org In-reply-to: <BAY7-F113qicRfZ7iHY0003b340 (AT) hotmail (DOT) com> References: BAY7-F113qicRfZ7iHY0003b340 (AT) hotmail (DOT) com Comments: In-reply-to "Gerard Mason" <gerardmason (AT) hotmail (DOT) com>message dated "Tue, 16 Dec 2003 14:18:54 +0000" Message-ID: <21035.1071584884 (AT) sss (DOT) pgh.pa.us X-Virus-Scanned: by amavisd-new at postgresql.org X-Mailing-List: pgsql-novice Precedence: bulk X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - noon.pghoster.com X-AntiAbuse: Original Domain - hotmail.com X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - postgresql.org Return-Path: pgsql-novice-owner+M9061 (AT) postgresql (DOT) org X-OriginalArrivalTime: 16 Dec 2003 14:33:43.0294 (UTC) FILETIME=[9B0DD9E0:01C3C3E1] "Gerard Mason" <gerardmason (AT) hotmail (DOT) com> writes: That seems to be what the documentation is suggesting the return type should be (the examples are very incomplete!), but it doesn't work (7.1.3, ^^^^^ That seems to be your problem ;-) and I can't upgrade without buying a new machine, which I don't want to do just yet). Surely you can upgrade. If the problem is lack of RPMs for whatever OS you are running, you could just compile Postgres from source. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org) |
#3
| ||||
| ||||
|
|
how do I declare return types that are a SETOF rows containing columns from an arbitrary query? |
|
For example, suppose I want a function that returns a display-formatted organisation, by joining with countries so that the country appears as a name rather than an integer. What is currently happening is that the client is sending the query: SELECT o.name, c.name AS country, o.phone, o.mobile, o.fax, o.email, o.website FROM organisations o, countries c WHERE c.id = o.country What I'd *like* to happen is that the client calls, say, get_org_long() and retrieves the same data. But what would the return type be? The only way I can think to do it at the moment would be to create a view and return a setof that view's rowtype, but that seems to be using a sledgehammer to crack a nut. |
|
Also my first attempt at defining a test function that just returns rows from the organisations table fails with the message: ERROR: parser: parse error at or near "%" It looks like this: CREATE FUNCTION gems_test() RETURNS SETOF organisations%ROWTYPE AS |
|
That seems to be what the documentation is suggesting the return type should be (the examples are very incomplete!), but it doesn't work (7.1.3, and I can't upgrade without buying a new machine, which I ^^^^^ |
#4
| |||
| |||
|
|
Well, is it possible to run two different versions of postgresql side-by-side on the same machine? I don't want to end up with a non-working database just because I've made some stupid mistake installing a new version, and then find that I can't revert back to the old one either. |
|
Is it at least possible to have two different versions installed side-by-side, even if you can only have one running at a time? |
#5
| |||
| |||
|
#6
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |