X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E268C9DC829 for ; Sun, 29 Jan 2006 22:01:37 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 51781-02 for ; Sun, 29 Jan 2006 22:01:41 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.201]) by postgresql.org (Postfix) with ESMTP id C8A7A9DC805 for ; Sun, 29 Jan 2006 22:01:35 -0400 (AST) Received: by xproxy.gmail.com with SMTP id i30so665930wxd for ; Sun, 29 Jan 2006 18:01:40 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=VwFIRpNiVcNowGBmjmdfz11bKnOvZkpfcZETV/jLVNF+UuGeKRDkt5nmG5EGvuirheaEegnK7GXQqiaGaO5BLa6SjMyBSPVnoSur2n3sBU6dzhafXN40GM9JY4w7YVk5zcX8ZraE4zD2G0kNVrn+5gT/HqkMS8cKTJKB1Vi+kVU= Received: by 10.70.61.8 with SMTP id j8mr6584339wxa; Sun, 29 Jan 2006 18:01:38 -0800 (PST) Received: by 10.70.78.8 with HTTP; Sun, 29 Jan 2006 18:01:37 -0800 (PST) Message-ID: <5a3d805c0601291801j7de16f2eq15a4cd9698dbc7e4@mail.gmail.com> Date: Mon, 30 Jan 2006 09:01:37 +0700 From: ody quraviharto To: pgsql-sql@postgresql.org Subject: variable scooping MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.096 required=5 tests=[AWL=0.096] X-Spam-Score: 0.096 X-Spam-Level: X-Archive-Number: 200601/208 X-Sequence-Number: 23997 hi all, I'm a newbie in postgresql. I've tried to make function but having trouble in variable scooping. here is the code in plpgsql: "declare tbl_name varchar:=3D'tbl_A'; begin =09=09if exists(select 1 from pg_tables where tablename=3Dtbl_name) then =09=09select count(*) from tbl_name; =09=09end if; end" the message was: syntax error in $1 in "select count(*) from $1". I thought variable 'tbl_name' was not recognized. Why ? Please need some help here. Thx very much.