File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Oracle/OAS and the fly likes Oracle merge same table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Oracle merge same table" Watch "Oracle merge same table" New topic

Oracle merge same table

Atul Mishra
Ranch Hand

Joined: Jun 08, 2006
Posts: 140

All, is it possible to use Oracle merge query within the same table.
Case is

1. Select if input.x and input.y combination exists in Table A
2. If a row exists update column C in Table A with inout.Z
3. If row doesnt exist insert the row

Can anyone provide me how to do this using merge ?

I wrote a procs to do this but believe a merge can handle it

Atul Mishra
Ranch Hand

Joined: Jun 08, 2006
Posts: 140
could anyone please help

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32819

Do you know how to merge two different tables into one? If so, you know the syntax and are all set up to try it and find out.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Vamsi Mohan
Ranch Hand

Joined: Jun 20, 2009
Posts: 80
You can use "insert with select" query to merge the records.

(SCJP5.0, IBM Rational Solution Designer, IBM Rational Architect, IBM RUP Designer)
Atul Mishra
Ranch Hand

Joined: Jun 08, 2006
Posts: 140
I am afraid I may need a little more help.
I have only done merge query which merges two tables.

I agree. Here's the link:
subject: Oracle merge same table
It's not a secret anymore!