ORACLE - Dynamic Sql using CLOB
<p>I have a table as described below</p>

<pre><code>SQL&gt; desc tab_script
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 SRLNO                                              NUMBER
 INSERT_SCRIPT                                      CLOB
</code></pre>

<p>insert_script is populated with insert statement. I want to execute insert script dynamically. I have written the following code, but does not work. </p>

<pre><code>DECLARE
  ln_type_id NUMBER:= 1;
  lcl_sql    clob;
BEGIN
 FOR rec IN ( SELECT * FROM tab_script )
 LOOP
   lcl_sql:= rec.insert_script;
   EXECUTE IMMEDIATE lcl_sql ;
 END LOOP;
 COMMIT;
END;
</code></pre>

<p>My oracle version
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production</p>