aggregates

From: Jade <thanh(at)ipinc(dot)com>
To: pgsql-sql(at)hub(dot)org
Subject: aggregates
Date: 1998-08-03 03:19:52
Message-ID: Pine.BSF.3.96.980802194851.5828B-100000@filesurfer.ipinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I was wonder if anyone has every done this before or if it is at all possible.
I have 3 tables formats,tree,items. The table creation are shown below. The values in
the table are also displayed.

CREATE TABLE formats (
type int4,
agregatename text
);

CREATE TABLE tree (
l1 char16,
l2 char16,
l3 char16,
l4 char16,
l5 char16,
ident int4,
type int4
);

CREATE TABLE items (
ident int4,
name text ,
address text,
email text,
url text,
title
);

INSERT INTO FORMATS VALUES(1,'name,email,url');
INSERT INTO TREE VALUES('level1','level2','level3',509,1);
INSERT INTO ITEMS VALUES(28,'foobar','1230 Xmarks Rd', 'foo(at)bar(dot)com','http://www.perl.pl');

I would like to get the results from ITEMS using returned results from FORMATS as ITEMS'
aggregate to prepare my select query.

I have tried to create a function:

CREATE FUNCTION displayformat(int4)
RETURNS text
AS 'select formats from formats where type= $1'
LANGUAGE 'sql';

and then do the below query:

SELECT displayformat(1) from ITEMS WHERE id=0028;

I get the below result:

displayformat
--------------
name,email,url
(1 row)

Welp! .. I wanted those results returned to me to be seen as aggregates that I would like to
select from ITEMS;

Is it possible to accomplish something like this? Maybe even in a different matter. I just thought
it would be good if I could have a way to set some sort of rule that states what aggregates I need
from the specified query in a table. Is this possible or do I need to somehow keep track of them
seperately (probably causing for the need of a separate query).

Thanks a lot.

-- Thanh

Browse pgsql-sql by date

  From Date Subject
Next Message Chairudin Sentosa Harjo 1998-08-03 03:32:35 Date format DD-MMM-YYYY
Previous Message David Rugge 1998-08-03 00:52:58 Converting a Sybase SQL script to a PostgreSQL script