Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Convert PL/SQL code to DBMS_SQL code

RE: Convert PL/SQL code to DBMS_SQL code

From: Mindaugas Navickas <mnavickas_at_yahoo.com>
Date: Sun, 17 Jun 2007 23:01:23 -0400
Message-ID: <000001c7b154$f3f83e10$6401a8c0@MN>


Hi Nizar,  

Take a look at this function that I wrote a while ago to accomplish the same task...  



/* -- Formattin the create partition statment -- */

   v_add_partition_stmt := 'ALTER TABLE ' || p_partition_table_name ||

       ' ADD PARTITION ' || p_partition_name ||

    ' VALUES LESS THAN ( TO_DATE('''|| p_high_value || ''',''YYYY-MM-DD
HH24''))' ||
    ' TABLESPACE ' || v_default_tablespace;
   IF v_subpartition_count > 0 THEN
   v_add_partition_stmt := v_add_partition_stmt || ' SUBPARTITIONS ' || v_subpartition_count ||

       ' STORE IN ' || '(' || v_default_tablespace || ')';    END IF;
   dbms_output.put_line(v_add_partition_stmt);
-- UTL_FILE.PUT_LINE(file_handle, v_add_partition_stmt);

   v_cursor2 := DBMS_SQL.OPEN_CURSOR;
   DBMS_SQL.PARSE(v_cursor2, v_add_partition_stmt, dbms_sql.native);    v_ReturnCode := DBMS_SQL.EXECUTE(v_cursor2);    IF DBMS_SQL.IS_OPEN(v_cursor2) THEN
     DBMS_SQL.CLOSE_CURSOR(v_cursor2);
   END IF;      RETURN 0;
EXCEPTION
   WHEN OTHERS THEN

     err_code := SQLCODE;

-- UTL_FILE.PUT_LINE(file_handle, 'ERR:ADD_P: '|| SQLERRM );
IF DBMS_SQL.IS_OPEN(v_cursor2) THEN DBMS_SQL.CLOSE_CURSOR(v_cursor2); END IF; RETURN err_code;

END; Regards
Mindaugas Navickas
Oracle&DB2 DBA

-----Original Message-----
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Nizar Ahmed
Sent: June 17, 2007 5:16 AM
To: oracle-l
Subject: Convert PL/SQL code to DBMS_SQL code  

I have code whose purpose is to add 4 partitions to a table every day 6 hourly. I need to convert this code to one using DBMS_SQL. I am not a good programmer, appreciate any help.  

--
http://www.freelists.org/webpage/oracle-l
Received on Sun Jun 17 2007 - 22:01:23 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US