pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jade <thanh@ipinc.com>
To: pgsql-sql@hub.org
Subject: aggregates
Date: Sun, 2 Aug 1998 20:19:52 -0700 (PDT)
Message-ID: <Pine.BSF.3.96.980802194851.5828B-100000@filesurfer.ipinc.com> (raw)

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@bar.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





view thread (2+ messages)  latest in thread

Message-ID: <Pine.BSF.3.96.980802194851.5828B-100000@filesurfer.ipinc.com>
Permalink:  ../Pine.BSF.3.96.980802194851.5828B-100000@filesurfer.ipinc.com/
Also on:    postgresql.org/message-id/Pine.BSF.3.96.980802194851.5828B-100000@filesurfer.ipinc.com

 · 

reply

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: thanh@ipinc.com, pgsql-sql@hub.org
  Subject: Re: aggregates
  In-Reply-To: <Pine.BSF.3.96.980802194851.5828B-100000@filesurfer.ipinc.com>
  References: <Pine.BSF.3.96.980802194851.5828B-100000@filesurfer.ipinc.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