From: Ramakrishnan Muralidharan <ramakrishnanm@pervasive-postgres.com>
To: Markus Bertheau ? <twanger@bluetwanger.de>
To: pgsql-sql@postgresql.org
Subject: Re: Impossible with pl/pgsql?
Date: Tue, 31 May 2005 10:10:00 +0530
Message-ID: <02767D4600E59A4487233B23AEF5C5992A408C@blrmail1.aus.pervasive.com> (raw)
Hi,
I have tried it on PostgreSQL 8.0.3 and following query gives the result
SELECT ( DECORATE( FIND )).* FROM FIND()
Regards,
R.Muralidharan
-----Original Message-----
From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org]On Behalf Of
twanger@bluetwanger.de
Sent: Monday, May 30, 2005 8:46 PM
To: 'pgsql-sql@postgresql.org'
Subject: [SQL] Impossible with pl/pgsql?
Hi,
I have a function find() that returns a SETOF INT. I further have a
function decorate as follows:
CREATE TYPE decorate_type AS (id INT, name TEXT, author TEXT,
last_change TIMESTAMP);
CREATE FUNCTION decorate(INT)
RETURNS decorate_type
STABLE
LANGUAGE 'plpgsql'
AS '
-- BLACK BOX
';
Now I can do
SELECT decorate(4);
(4,egg,john,2003-05-05)
and I can do
SELECT * FROM decorate(4);
id | name | author | last_change
--------------------------------
4 | egg | john | 2003-05-05
SELECT * FROM decorate(5);
id | name | author | last_change
--------------------------------
5 | ham | dave | 2004-03-01
Let's say find() gives me 4 and 5:
SELECT * FROM find();
find
----
4
5
Now how would a query look like that involves find() and decorate() and
returns
id | name | author | last_change
--------------------------------
4 | egg | john | 2003-05-05
5 | ham | dave | 2004-03-01
I can't figure this out for the life of me.
I also have the impression that that's impossible to do without changing
find() or decorate().
Markus
--
Markus Bertheau ☭ <twanger@bluetwanger.de>
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: ramakrishnanm@pervasive-postgres.com, twanger@bluetwanger.de
Subject: Re: Impossible with pl/pgsql?
In-Reply-To: <02767D4600E59A4487233B23AEF5C5992A408C@blrmail1.aus.pervasive.com>
References: <02767D4600E59A4487233B23AEF5C5992A408C@blrmail1.aus.pervasive.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox