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 45C9C329D83 for ; Mon, 13 Sep 2004 23:03:16 +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 63324-08 for ; Mon, 13 Sep 2004 22:03:09 +0000 (GMT) Received: from mail.atua.com.br (atua1.razaoinfo.com.br [201.3.177.18]) by svr1.postgresql.org (Postfix) with ESMTP id 1C4D1329E78 for ; Mon, 13 Sep 2004 23:03:09 +0100 (BST) Received: from [10.0.0.171] (ns2.atua.com.br [201.3.177.19]) by mail.atua.com.br (Postfix) with ESMTP id C77351EC061 for ; Mon, 13 Sep 2004 19:03:03 -0300 (BRT) Subject: Difficulties to use a Set Returning Function on a join From: Alvaro Nunes Melo To: PostgreSQL - SQL Content-Type: text/plain Message-Id: <1095112983.6693.5.camel@localhost> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 13 Sep 2004 19:03:03 -0300 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: 200409/97 X-Sequence-Number: 18943 Hi, I have a Set Returning Function that works great when called alone, but I'm having problems to join it with another table and use this table's primary key as the parameter for the SRF. I'm sending it with the names in Brazilian Portuguese, but I think it might be compreensible english speakers. This works fine: SELECT * FROM obtem_situacao_pedido(1); cd_pedido | cd_pedido_situacao | id_tipo -----------+--------------------+--------- 1 | 106 | 1 (1 row) But these doesn't: SELECT p.*, hsp.* FROM pedido p LEFT OUTER JOIN obtem_situacao_pedido(p.cd_pedido) hsp ON hsp.cd_pedido = p.cd_pedido; ERROR: Relation "p" does not exist SELECT p.*, hsp.* FROM obtem_situacao_pedido(p.cd_pedido) hsp RIGHT OUTER JOIN pedido p ON hsp.cd_pedido = p.cd_pedido; ERROR: Relation "p" does not exist SELECT osp.* FROM pedido p JOIN obtem_situacao_pedido(pedido.cd_pedido) osp USING(cd_pedido); NOTICE: Adding missing FROM-clause entry for table "pedido" ERROR: FROM function expression may not refer to other relations of same query level Thanks in advance, -- +---------------------------------------------------+ | Alvaro Nunes Melo Atua Sistemas de Informacao | | al_nunes@atua.com.br www.atua.com.br | | UIN - 42722678 (54) 327-1044 | +---------------------------------------------------+