[EMAIL PROTECTED] wrote:
it there a way to execute a SQL query generated by SELECT ?
for eg. :
select 'insert into plan (personid, curseid, statid) select
tbl.excelid, ' || id || ',status.id from tbl, status where
tbl.' || fldname || ' = status.name ;' from curses;
No, not really. You have a rather unusual database schema, what with one
table storing field names from another table. I'd reconsider this
design.
Assuming you insist on this structure, you can do something like this:
insert into plan (personid, curseid, statid)
select tbl.excelid, curses.id, status.id
from tbl, status, curses
where
(case curses.fldname
when 'fld1' then tbl.fld1
when 'fld2' then tbl.fld2
when 'fld3' then tbl.fld3
...
end) = status.name;
Igor Tandetnik