Function, that returns set of 2 tables columns - Mailing list pgsql-general

From Dmitriy Chumack
Subject Function, that returns set of 2 tables columns
Date
Msg-id 504136614.20070213154619@gmail.com
Whole thread Raw
Responses Re: Function, that returns set of 2 tables columns  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: Function, that returns set of 2 tables columns  ("Willy-Bas Loos" <willybas@gmail.com>)
Re: Function, that returns set of 2 tables columns  (Ron Johnson <ron.l.johnson@cox.net>)
List 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.d.a@gmail.com


pgsql-general by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: missing FROM-clause (more)
Next
From: "Cristiano Panvel"
Date:
Subject: Re: PostgreSQL and OpenLdap