DECLARE
SQLSTMT VARCHAR2(500);
CURSOR C1 IS SELECT DISTINCT 'GRANT FRS_JTO_OD
TO '||SDO_CODE ABC FROM EXCHANGE_SDO;
BEGIN
SQLSTMT:=NULL;
FOR V1 IN C1 LOOP
sqlstmt:=V1.ABC;
execute immediate (sqlstmt);
END LOOP;
END;
/
NOTE
:- Do not put ‘;’ in the sqlstmt
FOR DDL
DECLARE
SQLSTMT
VARCHAR2(500);
BEGIN
SQLSTMT:='CREATE
TEMPORARY TABLESPACE TEMP_new1 TEMPFILE ''/usr1/TEMP_new1.dbf'' SIZE 50M REUSE
AUTOEXTEND
ON NEXT 32 M MAXSIZE unlimited EXTENT MANAGEMENT LOCAL UNIFORM SIZE 32M';
execute
immediate (sqlstmt);
SQLSTMT:='ALTER
DATABASE DEFAULT TEMPORARY TABLESPACE TEMP_new1';
execute
immediate (sqlstmt);
SQLSTMT:='DROP
TABLESPACE TEMP_ABC INCLUDING CONTENTS AND DATAFILES';
execute
immediate (sqlstmt);
END;
/