Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

PLSQL/SQL Merging rows

Neils KhOct 23 2024 — edited Oct 23 2024

I have a table like

ID Identifier source value opendate closedate activeFlag
--------------------------------------------------------
101 euid01   File01 x010 01-01-2023 01-01-2999    1
101 euid02   File01 x111 01-01-2023 01-01-2999    1
101 euid02   File01 x222 01-01-2023 01-10-2024    0
102 euid01   File11 x010 01-01-2023 01-01-2999    1
102 euid02   File12 x333 01-01-2023 01-01-2999    1
102 euid02   File10 x444 01-01-2023 01-10-2024    0

I want to pass a values like (102,101) to merge 102 into 101 to a function or procedure to get the output as below, basically it should merge 102 into 101 and once merged delete 102

If the identifier and values are same for two different IDs ignore that rec during merge, closedate can be get sysdate or getdate in case of terming them out.

All the records in 102 will be termed out except which has Identifier and value same, in this case we ignore that record.

ID Identifier source value opendate closedate activeFlag
-----------------------------------------------------------
101 euid01 File01 x010 01-01-2023 01-01-2999 1 
101 euid02 File01 x111 01-01-2023 01-01-2999 1
101 euid02 File01 x222 01-01-2023 01-10-2024 0
101 euid02 File12 x333 01-01-2023 22-10-2024 0
101 euid02 File10 x444 01-01-2023 22-10-2024 0
Comments
Post Details
Added on Oct 23 2024
5 comments
180 views