I have tried everything I can think of but couldn\'t solve this SQL error:
SQL Error: ORA-00933: SQL command not properly ended
If you want to update rows from a subquery with more than one record you can use the merge commenad:
merge into SALES_DATA_FAMILY_2007 A
using (select POG_ID , FAMILY
FROM POG_HIERARCHY ) B
on (A.FAMILY_ID=B.FAMILY)
when matched then
update set A.POG_ID=B.POG_ID
Try this:
UPDATE SALES_DATA_FAMILY_2007 A
SET A.POG_ID =
(
SELECT P.POG_ID
FROM POG_HIERARCHY P
WHERE A.FAMILY_ID = P.FAMILY_ID
)
UPDATE SALES_DATA_FAMILY_2007 A
SET A.POG_ID= (select B.POG_ID
FROM POG_HIERARCHY B
WHERE A.FAMILY_ID=B.FAMILY)
WHERE A.POG_ID IN (SELECT C.POG_ID FROM POG_HIERARCHY C
WHERE A.FAMILY_ID = C.FAMILY);
UPDATE SALES_DATA_FAMILY_2007 A
SET A.POG_ID= (select B.POG_ID
FROM POG_HIERARCHY B
WHERE A.FAMILY_ID=B.FAMILY) ;
This will work if and only if there's at most one corresponding row in POD_HIERARCHY for a given FAMILY. If there's more than one row in POD_HIERARCHY, then you need to determine which row from POD_HIERARCHY you wish to use the value from.