Dynamic plpgsql code
Hi dear All,
I wander, is there a way to execute dynamic plpgsql code which is not restricted to sql command, but executes plpgsql code itself....
For example... I would like to form dynamically a part of the code which contains ...
"if-- end if... raise notice --- "
I have been using such possibilities in Oracle, so pls. tell me if this possibility somehow is given in PlPgsql as well?
Cheers,
Natasa
I can't answer your question, but I'm sure it's possible to use if
statements instead of dynamically generated plsql code, which will make
your code actually more readable.
The if statements should be there anyway in your dynamic code generation
code... unless you get the code completely from outside as parameter,
which would be a bad security hole.
Why not replace the dynamic plsql code with if statements and possibly
dynamic SQL ?
Cheers,
Csaba.
Show quoted text
On Mon, 2003-07-07 at 09:54, Natasa Bulatovic wrote:
Hi dear All,
I wander, is there a way to execute dynamic plpgsql code which is not restricted to sql command, but executes plpgsql code itself....
For example... I would like to form dynamically a part of the code which contains ...
"if-- end if... raise notice --- "
I have been using such possibilities in Oracle, so pls. tell me if this possibility somehow is given in PlPgsql as well?
Cheers,
Natasa
On Monday 07 Jul 2003 8:54 am, Natasa Bulatovic wrote:
Hi dear All,
I wander, is there a way to execute dynamic plpgsql code which is not
restricted to sql command, but executes plpgsql code itself....For example... I would like to form dynamically a part of the code which
contains ..."if-- end if... raise notice --- "
I have been using such possibilities in Oracle, so pls. tell me if this
possibility somehow is given in PlPgsql as well?
Well - I wrote a plpgsql function that created a plpgsql function, but that's
about all you could do. There's no "eval()" type of call.
You can, of course execute dynamically formed SQL so that handle some of your
requirements.
--
Richard Huxton
Sure, use EXECUTE in PL/pgSQL.
---------------------------------------------------------------------------
Natasa Bulatovic wrote:
Hi dear All,
I wander, is there a way to execute dynamic plpgsql code which is not restricted to sql command, but executes plpgsql code itself....
For example... I would like to form dynamically a part of the code which contains ...
"if-- end if... raise notice --- "
I have been using such possibilities in Oracle, so pls. tell me if this possibility somehow is given in PlPgsql as well?
Cheers,
Natasa
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073