Subject | How to run a built select-statement in a procedure |
---|---|
Author | Radovan Bukoci |
Post date | 2005-03-23T17:25:58Z |
Hello, please help me.
I need in a procedure to build a statement and then run it, for example
like this:
sele = 'SELECT ' || :col0 || ' AS Usek' || :fields || ' FROM ' ||
:source || :cond || ' GROUP BY ' || :col0 || ' INTO ' || :fields2;
for
execute :sele
do
begin
.... do something .....
end
end
but that "execute :sele" obviously doesn't work. And I don't know how to
put there the created statement to be run.
Because I have several possible :fields, several possible :sources and
several possible :col0, there are more than 100 possible combinations,
and I don't want to manually code more than 100 FOR SELECT DO
statements, which would also make the procedure huge.
I need in a procedure to build a statement and then run it, for example
like this:
sele = 'SELECT ' || :col0 || ' AS Usek' || :fields || ' FROM ' ||
:source || :cond || ' GROUP BY ' || :col0 || ' INTO ' || :fields2;
for
execute :sele
do
begin
.... do something .....
end
end
but that "execute :sele" obviously doesn't work. And I don't know how to
put there the created statement to be run.
Because I have several possible :fields, several possible :sources and
several possible :col0, there are more than 100 possible combinations,
and I don't want to manually code more than 100 FOR SELECT DO
statements, which would also make the procedure huge.