Define a procedure to drop a database object : Execute immediate « PL SQL Statements « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » PL SQL Statements » Execute immediate 
22. 16. 5. Define a procedure to drop a database object
SQL>
SQL>
SQL> CREATE TABLE product (
  2       product_name     VARCHAR2(25PRIMARY KEY,
  3       product_price    NUMBER(4,2),
  4       quantity_on_hand NUMBER(5,0),
  5       last_stock_date  DATE
  6       );

Table created.

SQL>
SQL>
SQL> CREATE OR REPLACE PROCEDURE dropit (ittype IN VARCHAR2, itname IN VARCHAR2)
  2  IS
  3  BEGIN
  4     EXECUTE IMMEDIATE 'drop ' || ittype || ' ' || itname;
  5  END;
  6  /

Procedure created.

SQL>
SQL> EXEC dropit('table','product');

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>
22. 16. Execute immediate
22. 16. 1. Simple EXECUTE IMMEDIATE
22. 16. 2. Call EXECUTE IMMEDIATE in Pl/SQL block
22. 16. 3. Execute sql statement in a procedure
22. 16. 4. 'execute immediate in' action
22. 16. 5. Define a procedure to drop a database object
22. 16. 6. Create a function to count table row
22. 16. 7. Use procedure to create an index dynamically
22. 16. 8. Call function and get result by using 'EXECUTE IMMEDIATE'
22. 16. 9. EXECUTE IMMEDIATE dynamic sql to alter session
22. 16. 10. Use 'execute immediate' to run a insert statement
22. 16. 11. select into rowtype then use it in 'execute immediate'
22. 16. 12. Quotation string
22. 16. 13. Use 'EXECUTE IMMEDIATE' to execute an update statement
22. 16. 14. Wrap 'EXECUTE IMMEDIATE' for current user
22. 16. 15. Wrap statement with 'BEGIN...END'
22. 16. 16. Catch exception from 'EXECUTE IMMEDIATE'
22. 16. 17. EXECUTE IMMEDIATE USING IN
22. 16. 18. Drop user, create user and grant permission with PL/SQL code
22. 16. 19. execute immediate into
22. 16. 20. Update row with 'execute immediate'
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.