Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 15. Table Operations > 15.5 MERGE Statement - Pg. 319

Chapter 15 TAblE OPErATIONS 319 FROM Bar WHERE Foo.col_a = Bar.col_a) = 1; 15 .5 MERGE Statement SQL-99 added a single statement to mimic a common magnetic tapefilesystem"mergeandinsert"procedure,butinarelational way.Thisisalsocalledan"upsert"intheliterature.Thesimplest business logic, in a pseudo-code, is like this: FOR EACH row IN the Transactions table DO IF working row NOT IN Master table THEN INSERT working row INTO the Master table; ELSE UPDATE Master table SET Master table columns to the Transactions table values WHERE they meet a matching criteria; END IF; END FOR; In the 1950s, we would sort the transaction tape(s) and Master