Doing an update with an oracle with clause?

I have a physical table that I'm populating with employee data except for three columns. I have the sql to determine how to populate the three columns but I'm using a with clause. How do I update the three columns in my table using a with clause in Oracle? I have several differant with clauses to update these three columns based on various data.
cobolinx1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
You didn't provide a lot of information so I had to do some assuming.

See if this test case will help you
drop table tab1 purge;
create table tab1(col1 char(1), col2 char(1), col3 char(1));

insert into tab1 values('a','b','c');
insert into tab1 values('b','c','d');
commit;

drop table tab2 purge;
create table tab2(col1 char(1), col2 char(1), col3 char(1));

insert into tab2 
(
select col1, col2,col3 from (
with myTab as ( select 'a' col1, '1' col2, '2' col3 from dual )
select col1,col2,col3 from myTab where col1='a'
)
)
/

Open in new window

0
cobolinx1Author Commented:
That's what I assumed. there is no way to run an update command with a WITH clause?
0
slightwv (䄆 Netminder) Commented:
Updates are similar.

given the example above
update tab2 set (col2, col3) =
(
select col2,col3 from (
with myTab as ( select 'a' col1, 'Z' col2, 'X' col3 from dual )
select col1,col2,col3 from myTab where col1='a'
)
)
/

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cobolinx1Author Commented:
Ok almost there I want to do something like this


update tab2 set col4 = 'TEST' where  (col2, col3) in
(
select col2,col3 from (
with myTab as ( select 'a' col1, 'Z' col2, 'X' col3 from dual )
select col1,col2,col3 from myTab where col1='a'
)
)

I get a single row subqury returns more then one row
how would I do that???
0
cobolinx1Author Commented:
I had to switch the to an in and it works great thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.