This is a discussion on Need Help - Any workaround? within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Greetings, Need some help to implement the following logic in, if possible, in a single SQL statement. Requirement: (1) ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Greetings, Need some help to implement the following logic in, if possible, in a single SQL statement. Requirement: (1) I have two tables say table1 and table2 (2) I have to iterate through table1 records and need to check some conditions against table2 records (3) When the conditions are NOT MATCHING I want to insert the same record(under consideration) of table1 into table2 (4) If conditions are MATCHING then I need to update some columns of table2 and insert the same record from table1 to table 2 (just like point 3). My approach was to do it using MERGE statement but I dont know how to update plus insert the records (i.e point 4) in the WHEN MATCHED clause of merge statement. Can someone give me some hint or some workaround? If possible, I want to avoid using cursors. I hope I was able to make myself clear Any help would be appreciated. TIA |