Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a variable for the partition name in an insert. 1

Status
Not open for further replies.

commatom

Programmer
Aug 30, 2007
54
US
I am trying to insert into a partitioned table while specifying the partition name.

The SQL looks like the following:

v_partition := 'ERG_GMT_'||part.gmtmonthid;

INSERT /*+ APPEND */ INTO dw.stg_erg_cdr partition (v_partition)
.....

when this runs I get a partition does not exist error.

I put in a DBMS OUTPUT to make sure I have the correct partition name and I do....Soooooooooo any suggestions?

Thanks in advance.
 
Try using "execute immediate":
Code:
declare
...
    v_sql_stm   varchar2(1000);
    v_partition varchar2(1000);
begin
    v_partition := 'ERG_GMT_'||part.gmtmonthid;
    v_sql_stm := 'INSERT /*+ APPEND */ INTO dw.stg_erg_cdr partition ('||v_partition||')';
    execute immediate v_sql_stm;
.....
Let us know your findings.



[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm. The cost will be your freedoms and your liberty.”
 
My pleasure ! Thanks for the
star.gif
.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
“Beware of those that seek to protect you from harm. The cost will be your freedoms and your liberty.”
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top