hi
I want to update a table from the back-end, which has the below data (example of 1 record, RETURNING 6 ROWS, based on dc_lease_no, present in its parent table, dc_lease_txn);
SQL> ed
Wrote file afiedt.buf
1 select a.dc_lease_no,
2 b.DC_LEASE_FROM_PERIOD,
3 add_months(b.DC_LEASE_FROM_PERIOD,1) DC_PDC_RENT_FROM,
4 add_months(b.DC_LEASE_FROM_PERIOD,1)-1 DC_PDC_RENT_UPTO
5 from dc_lease_pdc_chq a, dc_lease_txn b
6 where a.dc_pdc_lease_no = b.DC_LEASE_NO
7* and a.dc_lease_no = 10187
SQL> /
DC_PDC_LEASE_NO DC_LEASE_F DC_PDC_REN DC_PDC_REN
--------------- ---------- ---------- ----------
10187.000 01/10/2022 01/11/2022 31/10/2022
10187.000 01/10/2022 01/11/2022 31/10/2022
10187.000 01/10/2022 01/11/2022 31/10/2022
10187.000 01/10/2022 01/11/2022 31/10/2022
10187.000 01/10/2022 01/11/2022 31/10/2022
10187.000 01/10/2022 01/11/2022 31/10/2022
6 rows selected.
i want to update the table [u]dc_lease_pdc_chq[/u] by updating its DC_PDC_RENT_FROM & DC_PDC_RENT_UPTO columns,
for all the matching dc_lease_no of [u]dc_lease_txn[/u] table.
[i]for each dc_lease_no record of dc_lease_txn, theres is one or more matching dc_pdc_lease_no records in dc_lease_pdc_chq table.[/i]
after the update, the records for lease_no 10187 should look like the below result.
DC_PDC_LEASE_NO DC_LEASE_F DC_PDC_REN DC_PDC_REN
--------------- ---------- ---------- ----------
10187.000 01/10/2022 01/10/2022 31/10/2022
10187.000 01/10/2022 01/11/2022 30/11/2022
10187.000 01/10/2022 01/12/2022 31/12/2022
10187.000 01/10/2022 01/01/2023 31/01/2023
10187.000 01/10/2022 01/02/2023 28/02/2023
10187.000 01/10/2022 01/03/2023 31/03/2023
I wonder whether it's achievable with the update statement.
any help would be greatly appreciated, thanks