I was looking through the AskTom site and found what should be a very powerful tool for update statments but my statement refuses to accept the alias after the subquery.
Can someone please explain this for me and possibly show a solution?
Update (SELECT T.Date_,T.Name_
FROM TableA T, TableB P
WHERE P.Date_ = T.Date_
AND P.Name_ = T.Name_) SET P.ID = T.Name_
There may be other issues as to how to run this type of update and That would be a bonus. I am more interested at this point in trying to understand the alias problem. I have tried to sub in
TableB.ID = TableA.Name_
but no luck
Specifically the error is ORA-00904 invalid identifier.
As always thanks in advance.
The above issue has been answered for me but I do have some others as I try to understand it.
I now get ORA-01779 cannot modify a column which maps to a non-key preserved table.
I presume this is referring to the table I’m trying to update correct? As I could update from a view or any other proper source that may not have a pk or fk.
Can this type of update statement work with Oracle temp tables or can I expect problems?
Can I use this type of statement with a case statement to update multiple columns in TableA or will there be problems?
Thanks again.
When you perform an
UPDATE (query)operation, the only columns you can use outside the parentheses are the names of columns returned by the query – in this case Date_ and Name_. The table aliases you used in the query are not valid outside the parentheses either.What you therefore need is: