X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9E2C132A0FE for ; Fri, 1 Oct 2004 17:47:34 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 73898-03 for ; Fri, 1 Oct 2004 16:47:26 +0000 (GMT) Received: from postgres.pl (vs198.internetdsl.tpnet.pl [80.55.174.198]) by svr1.postgresql.org (Postfix) with ESMTP id 532A132A610 for ; Fri, 1 Oct 2004 17:47:24 +0100 (BST) Received: (qmail 49150 invoked from network); 1 Oct 2004 18:45:18 -0000 Received: from mr153.softel.elblag.pl (HELO postgres.pl) (ojciec@195.116.130.153) by 0 with SMTP; 1 Oct 2004 18:45:14 -0000 Message-ID: <415D89F5.10406@postgres.pl> Date: Fri, 01 Oct 2004 18:46:45 +0200 From: Marcin Piotr Grondecki Reply-To: ojciec@postgres.pl User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: SELECT with Function References: <2004929105149.835585@develop> In-Reply-To: <2004929105149.835585@develop> X-Enigmail-Version: 0.83.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/12 X-Sequence-Number: 19115 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paulo Nievierowski wrote: | PS: Excuses my poor english. Your english is excellent. MY is poor!! | I create plpgsql function "myfunc(integer)" thats returns of type | record with values from table X (the function decides what record must | be select). The parameter is an keyprod existing in table X and in | table A. | | It run well sending in psql: | SELECT * FROM myfunc( 10006530 ) as (vret1 numeric, vret2 numeric); | | The problem is: | I need return data from table A (this have column 'keyprod'). This | value (keyprod) must be passed as parameter to myfunc(). The result | must be a union of columns selected from table A and result of | myfunc(). | | How to create this query? It's possible? Yep. Look at this: drop table dupa cascade; create table dupa (a int, b int, c int); insert into dupa (a, b, c) values (1, 2, 3); insert into dupa (a, b, c) values (2, 3, 4); create or replace function ttt(int) returns record as ' declare ~ r record; begin ~ select * into r from dupa where ($1=a); ~ return r; end; ' language 'plpgsql'; And then: ojciec=# select * from ttt(1) as foo(aa int, bb int, cc int); ~ aa | bb | cc - ----+----+---- ~ 1 | 2 | 3 Is this what you need? - -- ojciec -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFBXYnyCAdl/NTXOsERAs/EAKCUq26LmG9N36vW/WXGC4i92Ci4VwCdF+eS fiiHtfCVDONxxldr4SC17TI= =tahv -----END PGP SIGNATURE-----