Home » SQL & PL/SQL » SQL & PL/SQL » Execute Immediate with DDL and Nested table (Oracle 11g)
Execute Immediate with DDL and Nested table [message #609823] Wed, 12 March 2014 14:43 Go to next message
andreaplanet
Messages: 1
Registered: March 2014
Junior Member
I have a problem trying to use an Execute Immediate statement containing a CREATE TABLE statement and a user defined Table Type. I get error ORA-22905 on Oracle 11g.
Is there any workaround to solve this issue?
CREATE TYPE MY_TABLE_TYPE AS TABLE OF VARCHAR2(30);  
/  
DECLARE  
    MT MY_TABLE_TYPE;  
BEGIN  
    SELECT * BULK COLLECT INTO MT FROM DUAL;  
    -- Two steps  
    EXECUTE IMMEDIATE 'CREATE TABLE MY_TABLE1 (A VARCHAR2(30))';  
    EXECUTE IMMEDIATE 'INSERT INTO  MY_TABLE1    SELECT * FROM TABLE(:T)' USING MT; -- OK  
    -- One step  
    EXECUTE IMMEDIATE 'CREATE TABLE MY_TABLE2 AS SELECT * FROM TABLE(:T)' USING MT; -- ERROR ORA-22905     
END;

The real code for the SELECT * FROM TABLE(:T) is quite dynamic (new table name at each execution) and slow. That's why I try to avoid creating the table in two steps (as done with MY_TABLE1). Also with two steps I can't use SELECT * but I have to specify all the columns (variable amount and over 100 columns).
Re: Execute Immediate with DDL and Nested table [message #609824 is a reply to message #609823] Wed, 12 March 2014 15:00 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

ORA-22905: cannot access rows from a non-nested table item
  *Cause:  attempt to access rows of an item whose type is not known at
           parse time or that is not of a nested table type
  *Action: use CAST to cast the item to a nested table type

I think you should open a SR to Oracle to get a clear answer on this.

Re: Execute Immediate with DDL and Nested table [message #609887 is a reply to message #609823] Thu, 13 March 2014 12:44 Go to previous message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
See my reply on OTN.

SY.
Previous Topic: Fatal SSL error calling secure web service from 11g
Next Topic: Regular expression
Goto Forum:
  


Current Time: Thu Apr 25 17:37:32 CDT 2024