SqlDbx Forum

SqlDbx

You are not logged in.

#1 2012-09-12 01:06:37

hoarder
Member

Suggestion - Add "Merge" to generate capabilities

As well as being able to generate SELECT, INSERT, UPDATE, ... from the Results could you also add MERGE (Oracle format). Occassionally I need to sync two databases and the use of the Merge would make this task much easier.

Offline

#2 2012-09-12 14:36:55

sqldbxhelp
Administrator

Re: Suggestion - Add "Merge" to generate capabilities

MERGE is very generic and flexible statement.
I am not sure how it can be generated in a way to be useful in different scenarios.
Can you provide an example.

Offline

#3 2012-09-17 01:45:54

hoarder
Member

Re: Suggestion - Add "Merge" to generate capabilities

Merge provides the capability to synchronise a table by inserting rows where the primary key does not exist or by updating rows where the primary key does exist. In situations where you cannot easily drop and reload the table due to referential integrity constraints, this provides an easy way to update a table. Example where this would be useful are: 1) where you have reference tables containing valid value lists; and 2) where you have master tables where there are multiple columns that can be maintained.

Example Merge:

merge into REF_TABLE
using (select 1 from DUAL) s
   on (REF_ID = 'DEFAULT_VALUE')
when matched then
  update set REF_VALUE = 'YES'
when not matched then
  insert (REF_ID,REF_VALUE)
  values ('DEFAULT_VALUE', 'YES')

Offline

Board footer

Powered by FluxBB