Method for conditionally updating or inserting a row into a table
First Claim
Patent Images
1. A computer-implemented method for applying a row from a source table to a destination table, the method comprising:
- selecting a first column from a source table;
selecting a second column from a destination table;
performing an outer join operation on the source table and the destination table using the first and second columns, the outer join designating the source table as being preserved;
updating each row in the destination table with a row from the results of the outer join operation containing a matching element in the first and second columns; and
inserting into the destination table each row from the results of the outer join operation with a non-matching element in the first and second columns,the method performing no more than one scan per table.
2 Assignments
0 Petitions
Accused Products
Abstract
The present invention provides the ability to alternatively update or insert a row into a table. This functionality is accomplished by merging a source table with a destination table such that the rows in the combined table are classified as an update row or an insert row. An identifier is inserted into each row to indicate its class. Examination of the identifier allows the row to be correctly inserted into the destination table or correctly updated in the destination table.
-
Citations
36 Claims
-
1. A computer-implemented method for applying a row from a source table to a destination table, the method comprising:
-
selecting a first column from a source table; selecting a second column from a destination table; performing an outer join operation on the source table and the destination table using the first and second columns, the outer join designating the source table as being preserved; updating each row in the destination table with a row from the results of the outer join operation containing a matching element in the first and second columns; and inserting into the destination table each row from the results of the outer join operation with a non-matching element in the first and second columns, the method performing no more than one scan per table. - View Dependent Claims (2, 3, 4)
-
-
5. A statement implementing a computer-implemented process for inserting a new row or updating an existing row in a database table, the process comprising the steps of:
-
selecting from a source table a first column comprising a plurality of elements; selecting from a destination table a second column comprising a plurality of elements; determining a set of matching rows based upon the success of a comparison operation on an element in the first column and an element in the second column; determining a set of non-matching rows based upon the failure of a comparison operation on the first column element and the second column element; updating the destination table with the set of matching rows; and inserting into the destination table the set of non-matching rows, the statement performing no more than one scan per table. - View Dependent Claims (6, 7, 8)
-
-
9. A computer-implemented method for upserting a source table with a destination table, the method comprising:
-
selecting from a source table a first column comprising a plurality of elements; selecting from a destination table a second column comprising a plurality of elements; updating a row in the destination table with a row from the source table upon the success of a comparison operation on an element in the first column of the row from the source table and an element in the second column of the row from the destination table; and inserting a row from the source table into the destination table upon the failure of a comparison operation on an element in the first column of the row from the source table and an element in the second column of the row from the destination table, the method using no more than one query language statement. - View Dependent Claims (10, 11, 12)
-
-
13. A computer implemented method for aggregating data in a database, comprising:
-
parsing from a single command line, a command, a source table, a destination table, a source key, and a destination key; comparing the source key in each row of the source table with the destination key in each row of the destination table; determining a set of update rows based upon the success of a comparison operation performed on the source key and the destination key; determining a set of insert rows based upon the failure of a comparison operation performed on the source key and the destination key; updating the destination table with the set of update rows; and inserting into the destination table the set of insert rows; wherein no more than one command line is parsed. - View Dependent Claims (14, 15, 16)
-
-
17. A computer program product including a medium usable by a processor, the medium having stored thereon a sequence of instructions, wherein when the sequence of instructions is executed by the processor, the processor executes a process for applying a row from a source table to a destination table, the process comprising:
-
selecting a first column from a source table; selecting a second column from a destination table; performing an outer join operation on the source table and the destination table using the first and second columns, the outer join designating the source table as being preserved; updating each row in the destination table with a row from the results of the outer join operation containing a matching element in the first and second columns; and inserting into the destination table each row from the results of the outer join operation with a non-matching element in the first and second columns; the process performing no more than one scan per table. - View Dependent Claims (18, 19, 20)
-
-
21. A computer program product including a medium usable by a processor, the medium having stored thereon a sequence of instructions, wherein when the sequence of instructions is executed by the processor, the processor executes a process for inserting a new row or updating an existing row in a database table using no more then one query language statement, the process comprising:
-
selecting from a source table a first column comprising a plurality of elements; selecting from a destination table a second column comprising a plurality of elements; determining a set of matching rows based upon the success of a comparison operation on an element in the first column and an element in the second column; determining a set of non-matching rows based upon the failure of a comparison operation on the first column element and the second column element; updating the destination table with the set of matching rows; and inserting into the destination table the set of non-matching rows, the no more than one query language statement performing no more than one scan per table. - View Dependent Claims (22, 23, 24)
-
-
25. A computer program product including a medium usable by a processor, the medium having stored thereon a sequence of instructions, wherein when the sequence of instructions is executed by the processor, the processor executes a process for upserting a source table with a destination table, the process comprising:
-
selecting from a source table a first column comprising a plurality of elements; selecting from a destination table a second column comprising a plurality of elements; updating a row in the destination table with a row from the source table upon the success of a comparison operation on an element in the first column of the row from the source table and an element in the second column of the row from the destination table; and inserting a row from the source table into the destination table upon the failure of a comparison operation on an element in the first column of the row from the source table and an element in the second column of the row from the destination table, the process using no more than one query language statement. - View Dependent Claims (26, 27, 28)
-
-
29. A computer program product including a medium usable by a processor, the medium having stored thereon a sequence of instructions, wherein when the sequence of instructions is executed by the processor, the processor executes a process for aggregating data in a database, the process comprising:
-
parsing from a single command line, a command, a source table, a destination table, a source key, and a destination key; comparing the source key in each row of the source table with the destination key in each row of the destination table; determining a set of update rows based upon the success of a comparison operation performed on the source key and the destination key; determining a set of insert rows based upon the failure of a comparison operation performed on the source key and the destination key; updating the destination table with the set of update rows; and inserting into the destination table the set of insert rows; wherein no more than one command line is parsed. - View Dependent Claims (30, 31, 32)
-
-
33. A computer-implemented system for upserting a source table with a destination table, the system comprising:
-
logic for selecting from a source table a first column comprising a plurality of elements; logic for selecting from a destination table a second column comprising a plurality of elements; logic for updating a row in the destination table with a row from the source table upon the success of a comparison operation on an element in the first column of the row from the source table and an element in the second column of the row from the destination table; and logic for inserting a row from the source table into the destination table upon the failure of a comparison operation on an element in the first column of the row from the source table and an element in the second column of the row from the destination table, the system using no more than one query language statement. - View Dependent Claims (34, 35, 36)
-
Specification