Search Postgresql Archives

Re: can a function have a setof (returned from another function) as input

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

2011/3/28 Terry Kop <terry.kop@xxxxxxxxxxxxxxxx>:
> I'm trying to create a function that will take setof results from various
> other functions (they all produce the same output format). Is this possible?
> if so how do call it.

No, this isn't possible.

Regards

Pavel Stehule


>
> ex.
> CREATE TYPE emp_t AS (
> IDÂÂÂÂÂÂÂÂ int,
> nameÂÂÂÂÂÂ varchar(10),
> ageÂÂÂ ÂÂ int,
> salaryÂÂÂÂ real,
> start_date date,
> cityÂÂÂÂÂÂ varchar(10),
> regionÂÂÂÂ char(1)
> );
>
> CREATE OR REPLACE FUNCTION func1() RETURNS SETOF emp_t AS $$
> DECLARE
> Âv_row emp_t;
> BEGIN
> Â FOR v_row in SELECT * from employee
> Â LOOP
> ÂÂÂ RETURN NEXT v_row;
> Â END LOOP;
> END;
> $$ LANGUAGE plpgsql;
>
> CREATE OR REPLACE FUNCTION func2() RETURNS SETOF emp_t AS $$
> DECLARE
> Âv_row emp_t;
> BEGIN
> Â FOR v_row in SELECT * from diff_table_or constraints
> Â LOOP
> ÂÂÂ RETURN NEXT v_row;
> Â END LOOP;
> END;
> $$ LANGUAGE plpgsql;
>
> CREATE OR REPLACE FUNCTION myanalyze(in_t emp_t) RETURNS SETOF <something>
> AS $$
> DECLARE
> Âv_row emp_t;
> BEGIN
> Â FOR v_row in EXECUTE in_t
> Â LOOP
> ÂÂÂ -- do something
> ÂÂÂ RETURN NEXT v_row;
> Â END LOOP;
> END;
> $$ LANGUAGE plpgsql;
>
> -- so I would like the call to be something like
> select * from myanalyze(select * funct1());
> or
> select * from myanalyze(select * funct2());
>
>
> ______________________________
>
> Terry Kop
>
> Database Developer
>
> Clear Capital
>
>
>
> office: 530.550.2500, ext. 2589
>
> terry.kop@xxxxxxxxxxxxxxxx
>
>
>
> www.ClearCapital.com
>
>
>
>
>
> Clear Capital is a trade name of ClearCapital.com, Inc. The information
> contained in this email is for the exclusive use of its intended
> recipient(s) and may contain confidential information. All parties other
> than the intended recipient(s) should refrain from disseminating or
> otherwise using this information. If you have received this information in
> error, please immediately notify the sender, delete this information from
> your computer, and destroy all copies of the information. Clear Capital
> reserves the right to delete consumer non-public information from the
> contents of any email to which it responds.
>

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux