Search This Blog

Monday 28 March 2016

IBM Infosphere Datastage Merge Stage is same as Oracle Merge SQL statement

 

If we know how Oracle merge statement works, its easy to work with Datastage merge as both do similar things though not exactly same.

If we want to update/insert records to table A based on selection criteria from multiple tables its better to write ORACLE MERGE SQL instead of individual UPDATE/INSERT statements. But this may have performance impact if we are writing ORACLE Merge.

On other hand, DataStage MERGE stage will only do the update.

MERGE works with the concept that we have 1 master table and we want to update master table based on the selection criteria from update tables using key fields.

Below table compares ORACLE MERGE and DataStage MERGE assuming DataStage merge is processing tables (DataStage Merge could also process files, datasets)
 

 ORACLE MERGEDATASTAGE MERGE
Master TableCan have only one master tableCan have only one master table
Update TableCan have many update tablesCan have many update tables
Output record countORACLE MERGE can do INSERT, UPDATE and DELETE.. Therefore record count could increate, decrease or same after merge operationwill remain same if unmatched master records are kept otherwise will be less if unmatched master records are dropped
Output column countOracle MERGE can not add columns to master table therefore column count will remain unchanged after merge operation. Note: both master table and target tables are same in ORACLE Mergemaster and target tables are different therefore new columns from update tables can be added
Can we capture unmatched update tables recordsNoYes, using the reject links
What happens to records unmatched in master tableswill remain unchanged and delivered to targetcan be kept in master or dropped from master table
When matchedwe can perform insert, update or deleteonly update
when unmatchedwe can perform insert, update or deletewe can only drop or keep records from master table
deterministic?cannot update the same row of the target table multiple times in the same MERGE statementSame row can be updated multiple time is master record is matched with different update table records
Duplicates?No, if duplicate records in master or update tables present for the match fields (key fields) then oracle thinks its updating same record again and again so it will failNo, duplicates must be removed from master and update tables before processing merge

No comments:

Post a Comment