From: | Dmitriy Chumack <saint(dot)d(dot)a(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Function, that returns set of 2 tables columns |
Date: | 2007-02-13 13:46:19 |
Message-ID: | 504136614.20070213154619@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi *
I need to write a function, that returns a set of all columns from 2
tables.
e.g. I create such a function:
CREATE OR REPLACE FUNCTION func(val_ int8)
RETURNS SETOF record AS
$BODY$
DECLARE
i record;
BEGIN
for i in select * from "Table1", "Table2"
loop
return next i;
end loop;
return;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION func(val_ int8) OWNER TO postgres;
But when I try to call it like this:
SELECT * FROM func1(10);
I have an error:
ERROR: a column definition list is required for functions returning
"record"
This two tables have about 20 columns together, so I don't want list
them each I call this function. Can I achieve this in some other
(right) way?
P.S. I don't want to create a specific type for this purpose, but
if there is no other way, I should.
Thanks in advance.
--
Best regards,
Dmitriy Chumack mailto:saint(dot)d(dot)a(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Ray Bannon | 2007-02-13 13:46:32 | Union Query Improvement |
Previous Message | Fernando Schapachnik | 2007-02-13 13:31:21 | Infinite loop in transformExpr() |