HI all
What is the purpose of 'EXECUTE IMMEDIATE' statement in the PLSQL block. What purpose does it serve and how is it used? The reason I am asking is that I want to use multiple sql statements in PLSQL block?
Amol
Printable View
HI all
What is the purpose of 'EXECUTE IMMEDIATE' statement in the PLSQL block. What purpose does it serve and how is it used? The reason I am asking is that I want to use multiple sql statements in PLSQL block?
Amol
http://www.dbasupport.com/oracle/ora8/page6.shtml
In the future try to search before, there are a lot of threads on this topic in this forum.
Cheers
Angel
EXECUTE IMMEDIATE IS A DYNAMIC STATEMENT. You can use this statement for example,
DECLARE
v_stmt VARCHAR2(200);
BEGIN
v_stmt :='TRUNCATE TABLE DEPT';
EXECUTE IMMEDIATE v_stmt;
END;
It truncates the DEPT table. If I am not wrong it is just replacement of DBMS_SQL package, which we use normally for DYNAMIC SQLS.
Correct me If I am wrong.
All I'm going to add is that it's a God Send compared to the dynamic cursors needed in Oracle8 to perform the same function.
Cheers