Marcin Mazurek wrote:
[Charset iso-8859-2 unsupported, filtering to ASCII...]
> Hi,
> why I can't use tabb variable in INSERT ?
> The error message I get is:
> ERROR: parser: parse error at or near "$1"
>
> DECLARE
> ids1 INTEGER; ids2 INTEGER;
> tab TEXT; tabb TEXT;
> ...
> tab := TG_RELNAME;
> tabb :=tab || ''_do_zablokowania'';
> ...
> if (NEW.stan=ids1) then
> INSERT INTO tabb (zlecenie) VALUES ( OLD.id);
> --line that casues the trouble
> end if;
> ...
> tia
>
> Marcin Mazurek
Because the backends main parser doesn't allow a parameter in
place of an identifier. PL/pgSQL uses parameters in SPI
queries to substitute local variables into queries.
In 7.1 there is a new "EXEC <string expr>" command in
PL/pgSQL. If you succeed in building a complete (correctly
quoted) querystring for the operation, then you could use
that for a while.
I know that there are some problems with PL/pgSQL. I plan a
complete rewrite when other features in the core DB system
are available.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #