From: ody quraviharto <odyyudah@gmail.com>
To: pgsql-sql@postgresql.org
Subject: variable scooping
Date: Mon, 30 Jan 2006 09:01:37 +0700
Message-ID: <5a3d805c0601291801j7de16f2eq15a4cd9698dbc7e4@mail.gmail.com> (raw)
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:='tbl_A';
begin
if exists(select 1 from pg_tables where tablename=tbl_name) then
select count(*) from tbl_name;
end 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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: odyyudah@gmail.com
Subject: Re: variable scooping
In-Reply-To: <5a3d805c0601291801j7de16f2eq15a4cd9698dbc7e4@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox