From: | Jan Wieck <janwieck(at)Yahoo(dot)com> |
---|---|
To: | Marcin Mazurek <M(dot)Mazurek(at)poznan(dot)multinet(dot)pl> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: plpgsql, insert with wariables in function triggered |
Date: | 2000-10-23 13:48:29 |
Message-ID: | 200010231348.IAA01374@jupiter.jw.home |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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(at)Yahoo(dot)com #
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-10-23 13:54:52 | Re: Weird effects using BLOBs from libpq |
Previous Message | Warren Flemmer | 2000-10-23 13:35:18 | Update deleting records? |