Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id AA2009FBA34; Mon, 18 Jun 2007 10:14:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 85267-03; Mon, 18 Jun 2007 10:14:49 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 10C679FBA1E; Mon, 18 Jun 2007 10:14:50 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from sr01-05.mta.terra.com.br (sr01-05.mta.terra.com.br [200.154.152.24]) by svr4.postgresql.org (Postfix) with ESMTP id 0CCB65AF03B; Mon, 18 Jun 2007 13:14:48 +0000 (GMT) Received: from peguis.hst.terra.com.br (peguis.hst.terra.com.br [200.176.10.32]) by bulimba.hst.terra.com.br (Postfix) with ESMTP id 562EB15841A2; Mon, 18 Jun 2007 10:14:43 -0300 (BRT) X-Terra-Karma: -2% X-Terra-Hash: 8af00ae4dcb6c7531fd4f4387c4aae41 Received-SPF: pass (peguis.hst.terra.com.br: domain of terra.com.br designates 200.176.10.32 as permitted sender) client-ip=200.176.10.32; envelope-from=ranieri.oliveira@terra.com.br; helo=[172.16.2.72]; Received: from [172.16.2.72] (200-162-219-207.corp.ajato.com.br [200.162.219.207]) (authenticated user ranieri.oliveira) by peguis.hst.terra.com.br (Postfix) with ESMTP id 0818E2C1C2; Mon, 18 Jun 2007 10:14:42 -0300 (BRT) Message-ID: <46768538.9070909@terra.com.br> Date: Mon, 18 Jun 2007 10:14:32 -0300 From: Ranieri Mazili User-Agent: Thunderbird 2.0.0.4 (Windows/20070604) MIME-Version: 1.0 To: pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Exec a text variable as select Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.622 tagged_above=0 required=5 tests=AWL=-0.287, BAYES_50=0.001, DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_POST=1.708 X-Spam-Level: * X-Archive-Number: 200706/1037 X-Sequence-Number: 115860 Hello, I'm creating a function that will create a select statement into a while, this select will be stored into a text variable, after while ends I need to execute this query stored into variable, on SQLSERVER I can do: EXEC(text_variable) How can I do this on Postgres? I appreciate any help Thanks