Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can WITH clause be used with a insert statement?

Ryansun-OracleAug 14 2012 — edited Aug 14 2012
Hi There,

Can we use a SQL with clause in an insert statement,

Something like
create table tem (l number)

insert into tem
(l)
(with 
  t0  as 
  (Select exp_amt as t0 from exp_main)
select t0 from t0)
The with statement in itself works fine, but it throws the following error with insert
Error at Command Line:8 Column:17
Error report:
SQL Error: ORA-32034: unsupported use of WITH clause
32034. 00000 -  "unsupported use of WITH clause"
*Cause:    Inproper use of WITH clause because one of the following two reasons
           1. nesting of WITH clause within WITH clause not supported yet
           2. For a set query, WITH clause can't be specified for a branch.
           3. WITH clause can't sepecified within parentheses.
*Action:   correct query and retry
The reason I am using this format is because, we are trying to generate sqls from Analytics and the queries are generally formed like this. So instead of modifying the big queries, I was hoping we were able to insert it.

Please advise

thanks
Sun

Edited by: ryansun on Aug 14, 2012 1:59 AM
This post has been answered by user13117585 on Aug 14 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 11 2012
Added on Aug 14 2012
5 comments
6,999 views