Patent ID: 7206784

Claim:
A method of combining data in a database system, the method comprising: receiving a database command, in the Structured Query Language (SQL), that includes a first MERGE operator that specifies a first merge operation and a second MERGE operator that specifies a second merge operation; wherein, within the database command, the first MERGE operator is located in a position, relative to the second MERGE operator, that indicates that (a) the first merge operation is nested relative to the second merge operation, and (b) results of the first merge operation are to be used as a source stream of the second merge operation; executing the database command within the database server by performing the steps of: obtaining source data from a source data structure by performing a single scan of the source data structure; without performing any additional scans of the source data structure, performing a plurality of merge operations including the first merge operation and the second merge operation; wherein the first merge operation produces a first result, and wherein the second merge operation produces a second result by merging the first result into a destination data structure.