Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to call DDL statements from pl/sql?

Answer Posted / pavan_1981

One can call DDL statements like CREATE, DROP, TRUNCATE,
etc. from PL/SQL by using the "EXECUTE IMMEDATE" statement.
Users running Oracle versions below 8i can look at the
DBMS_SQL package .
begin
EXECUTE IMMEDIATE 'CREATE TABLE X(A DATE)';
end;
NOTE: The DDL statement in quotes should not be terminated
with a semicolon.

Another way is One can also use the older DBMS_SQL package
(V2.1 and above) to execute dynamic statements. Look at
these examples:
CREATE OR REPLACE PROCEDURE DYNSQL AS
cur integer;
rc integer;
BEGIN
cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(cur, 'CREATE TABLE X (Y DATE)',
DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(cur);
DBMS_SQL.CLOSE_CURSOR(cur);
END;
/


Is This Answer Correct ?    28 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to decrement dates by 1 in mysql? : Sql dba

1072


How do I run a script in sql developer?

997


Which tcp/ip port does sql server run on? How can it be changed? : Sql dba

1055


how does a local variable is defined using t-sql? : Transact sql

1059


what is meant by nl2br()? : Sql dba

1105


How consistent is the view of the data between and within multiple sessions, transactions or statements ?

2270


What is sqlca in powerbuilder?

1065


What is a procedure in pl sql?

1286


What is the usage of the distinct keyword?

1274


define sql delete statement ? : Sql dba

1068


What is the use of function in sql?

1149


What is dml statement?

999


Why stored procedure is faster than query?

1154


How many joins in sql?

1055


Define join and name different types of joins?

1052