Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Convert PL/SQL code to DBMS_SQL code
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
' 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;
-----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-lReceived on Sun Jun 17 2007 - 22:01:23 CDT
![]() |
![]() |