How can we update multiple columns in multiple tables in a single query?
I tried the below but no success.
update Class c, School s
set c.Status='Absent', s.Status='Absent'
Where c.ID='&ID' and c.ID=s.ID;
Any clues are appreciable.
How can we update multiple columns in multiple tables in a single query?
I tried the below but no success.
update Class c, School s
set c.Status='Absent', s.Status='Absent'
Where c.ID='&ID' and c.ID=s.ID;
Any clues are appreciable.
You can't do a direct update of multiple tables in Oracle.
You might be able to do an update of a view, like this:
update (
select c.status class_status, s.status school_status
from Class c, School s
Where c.ID='&ID' and c.ID=s.ID )
set class_status='Absent', school_status='Absent'
Oracle will only allow this if the join between the tables preserves keys - i.e. each row produced by the join directly maps to a single row in the source table(s) being updated. I suspect that in this case that School
is not key-preserved as each row in that table probably relates to more than one row in Class
. So you won't be able to do this in a single statement.
Oracle is far less tolerant of fuzzy relational thinking than other systems.