Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 3C6D31337B51 for ; Sat, 18 Dec 2010 08:54:59 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 54445-03 for ; Sat, 18 Dec 2010 12:54:53 +0000 (UTC) X-Greylist: delayed 00:08:13.039601 by SQLgrey-1.7.6 Received: from outbound003.roc2.bluetie.com (outbound003.roc2.bluetie.com [208.89.132.143]) by mail.postgresql.org (Postfix) with ESMTP id C330A133616B for ; Sat, 18 Dec 2010 08:54:51 -0400 (AST) Received: from web014.roc2.bluetie.com ([10.200.2.8]) by outbound003.roc2.bluetie.com with bizsmtp id kcme1f0010ANDLA01cmegL; Sat, 18 Dec 2010 07:46:38 -0500 X-CMAE-OUT-Analysis: v=1.1 cv=dKFuiD0dfRzTBSlX0E04TtFuYqejhXKRfUpdOIH4Uwk= c=1 sm=1 a=UCssvr9ZjTcA:10 a=IkcTkHD0fZMA:10 a=rfwCPAibizXczmtR5CYA:9 a=yfuNeWDfMpY6MqNUPCnuh2GkLSQA:4 a=QEXdDO2ut3YA:10 a=+8qXc097eLrkhNZCekYbQQ==:117 X-CMAE-OUT-Score: 0.00 Received: from web014.roc2.bluetie.com (localhost.localdomain [127.0.0.1]) by web014.roc2.bluetie.com (Postfix) with ESMTP id 27AA9AD0224 for ; Sat, 18 Dec 2010 07:46:38 -0500 (EST) Message-ID: <20101218074638.18205@web014.roc2.bluetie.com> X-HTTP-Received: from affox.myway [93.182.9.60] by web014.roc2.bluetie.com (BlueTie WebMail ); Sat, 18 Dec 2010 07:46:38 -0500 X-Mailer: BlueTie MTA Date: Sat, 18 Dec 2010 07:46:38 -0500 Cc: To: pgsql-sql@postgresql.org From: "Andrey Fokin" Importance: normal Subject: Table name as a variable in SELECT query Content-transfer-encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.888 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RFC_ABUSE_POST=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201012/88 X-Sequence-Number: 34924 Hi, please advise is possible in SELECT query use variable as a table name? I would like to have for example something like: CREATE OR REPLACE FUNCTION test_name (tb varchar) RETURNS int AS $$ DECLARE = ...... BEGIN SELECT * FROM $1; ........ Will be grateful for any idea about. = Best regards Andrey =