First, separate you queries with a semicolon and fix your SET
conditions:
CREATE VIEW cambiodatos AS
SELECT
a.last_name||','||a.first_name AS "Nombre",
a.salary AS "Salario",
b.name AS "Nombre Departamento",
c.name AS "Nombre de Region"
FROM
s_emp a, s_dept b, s_region c
WHERE
a.dept_id = b.id AND b.region_id = c.id;
UPDATE
cambiodatos
SET
name = 'North America'
WHERE
last_name = 'Biri'
AND first_name = 'Ben'
That's the reason of your error ORA-00933
Second, your UPDATE
statement will fail, as the view you created does not contain field name
.
This query will compile:
UPDATE
cambiodatos
SET
"Nombre de Region" = 'North America'
WHERE
"Nombre" = 'Biri, Ben'
, but most probably will fail as s_region
is not key-preserved
in this view.
To update, use this instead:
MERGE
INTO s_region c
USING (
SELECT b.region_id
FROM s_emp a, s_dept b
WHERE a.last_name || ',' || a.first_name = 'Biri, Ben'
AND b.id = a.dept_id
) q
ON c.id = q.region_id
WHEN MATCHED THEN
UPDATE
SET c.name = 'North America'