This content has been marked as final. Show 3 replies
You don't need execute immediate for this, and, more importantly, you shouldn't use execute immediate for this.
Execute immediate will parse your statement everytime.
PL/SQL was invented to reduce parsing.
For the rest, your request looks like homework, and if we are going to do your homework, you will never learn PL/SQL.
Senior Oracle DBA
I tried achieving this by referring http://www.adp-gmbh.ch/ora/plsql/bc/execute_immediate.html
The challenges I had was that I could not pass the table name as parameter and also could understand how to insert the column name that is used as part of execute immediate into a table as one of the values.
Not knowing the table to insert to, means a flawed database model. And flawed application code.
There needs to be sound and robust justification for using dynamic SQL. And seeing an example of that on the web and thinking "+oh, what a shiny idea, I'll copy and use it!+" is not justification.
We see dynamic SQL questions here in this forum, every single day. I cannot recall when last I've seen a valid question about using dynamic SQL. Invariable it is the wrong approach, for the wrong reasons.
Nothing in your postings makes me think your problem is an exception - and valid use of dynamic SQL. Or that you even bothered to read the manual.
If you want to see how execute immediate works, it is covered in chapter 7 of the Oracle® Database PL/SQL Language Reference.