I have a table with only 1 column which has several details concatenated into it like Product Name, Shipment Date etc:
MASTERCOLUMN
Row1_Prod1_ShipDate_01-Dec-21
Row2_Prod2_ShipDate_03-Dec-21
Row3_Prod3_ShipDate_07-Dec-21
.
.
The requirement is to add another 2 columns containing only ProductName and ShipmentDate details corresponding to MASTERCOLUMN: (Eg below)
MASTERCOLUMN ProductName ShipmentDate
Row1_Prod1_ShipDate_01-Dec-21 Prod1 01-Dec-21
Row2_Prod2_ShipDate_03-Dec-21 Prod2 03-Dec-21
Row3_Prod3_ShipDate_07-Dec-21 Prod3 07-Dec-21
.
.
.
I've altered the table and added these new columns. Is there any way of updating the table so that corresponding values gets copied to these new columns? Can this be achieved using SQL query? I am using SQL Developer with Oracle 19.c version.
I've tried updating the column after adding the 2 columns.. The below sample query is for updating the ProductName column:
UPDATE TABLE
SET ProductName = (SELECT SUBSTR(MASTERCOLUMN,6,5) FROM TABLE);
But this returns ORA-01427: single-row subquery returns more than one row error.
However, I tried to update only one row and it worked fine;
UPDATE TABLE
SET ProductName = (SELECT SUBSTR(MASTERCOLUMN,6,5) FROM TABLE)
WHERE MASTERCOLUMN = 'Row1_Prod1_ShipDate_01-Dec-21';
But I need to populate the entire table with corresponding values from MASTERCOLUMN column..