Skip to Main Content

Oracle Database Discussions

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!

How to MERGE Without Passing Field-List?

3199789Aug 8 2016 — edited Aug 10 2016

Hello

Is it possible to perform a MERGE operation without including a field-list?

By comparison, we can SELECT, DELETE, and INSERT without identifying each field. These are valid Oracle SQL:

SELECT * FROM MyTable;

DELETE FROM MyTable;

INSERT INTO MyTable VALUES ('Jack', 'White');

Can we eliminate the field-list in a MERGE statement? The bold part is what i'd like to remove-- can MERGE match positionally, or match same-named columns?

MERGE INTO dest_tab tt

  USING source_tab st

  ON (tt.id = st.id)

  WHEN MATCHED THEN

  UPDATE SET tt.code = st.code,

  tt.description = st.description;

The purpose is to avoid listing fieldnames in the query, so that the query can adapt to changed fieldnames (in both tables) without breaking.

thx!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 7 2016
Added on Aug 8 2016
13 comments
4,053 views