dbTalk Databases Forums  

INSERT and WITH

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss INSERT and WITH in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Hans Mayr
 
Posts: n/a

Default INSERT and WITH - 04-30-2009 , 04:11 AM






Hello,

I wrote a statement that contains a WITH clause:

SQL A: WITH ... AS adata SELECT ... FROM adata

It works fine. Now I wanted to insert the result into a table

SQL B: INSERT INTO tableA (col1, col2 .....) (WITH ... AS adata
SELECT ... FROM adata)

While the SQL A works fine, SQL B does not work. In SQL Developer
simply nothing happens, my DBA tells me that he got the error message
"ORA-32034: unsupported use of WITH clause".

I also tried something like:

SQL C: WITH ... AS adata INSERT INTO tableA (col1, col2 .....)
(SELECT ... FROM adata)

But now I get an "ORA-00928: missing SELECT statement".

Is there a solution for this? I did not find documentation on the
combination of WITH and INSERT.

Thanks in advance.

Hans

Reply With Quote
  #2  
Old   
Maxim Demenko
 
Posts: n/a

Default Re: INSERT and WITH - 04-30-2009 , 04:48 AM






Hans Mayr schrieb:
Quote:
Hello,

I wrote a statement that contains a WITH clause:

SQL A: WITH ... AS adata SELECT ... FROM adata

It works fine. Now I wanted to insert the result into a table

SQL B: INSERT INTO tableA (col1, col2 .....) (WITH ... AS adata
SELECT ... FROM adata)

While the SQL A works fine, SQL B does not work. In SQL Developer
simply nothing happens, my DBA tells me that he got the error message
"ORA-32034: unsupported use of WITH clause".

I also tried something like:

SQL C: WITH ... AS adata INSERT INTO tableA (col1, col2 .....)
(SELECT ... FROM adata)

But now I get an "ORA-00928: missing SELECT statement".

Is there a solution for this? I did not find documentation on the
combination of WITH and INSERT.

Thanks in advance.

Hans
Something like this should work:

SQL> create table emp_copy as
2 select * from emp where 1=2
3 /

Table created.

SQL> insert into emp_copy
2 with t as ( select * from emp)
3 select * from t
4 /

14 rows created.

SQL> commit
2 /

Commit complete.




Best regards

Maxim


Reply With Quote
  #3  
Old   
Hans Mayr
 
Posts: n/a

Default Re: INSERT and WITH - 04-30-2009 , 10:16 AM



Well, Thanks a lot. So there is only one version of the INSERT syntax
that works with WITH. Very logical.

Best,

Hans


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.