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