user2978621
user2978621

Reputation: 813

Oracle Table Update Exception ORA-0090

Hi I am trying to run query to update my oracle table .Following is the code

UPDATE analysis_oracle_upd t1
SET
  (c)
  =
  (SELECT t2.c FROM analysis_oracle_upd2 WHERE t1.a = t2.a
  )
WHERE EXISTS
  (SELECT 1 FROM analysis_oracle_upd2 t2 WHERE t1.a=t2.a
  );

But I am getting this exception :

SQL Error: ORA-00904: "T2"."A": invalid identifier
00904. 00000 -  "%s: invalid identifier"

Following is the schema for two tables :

create table analysis_oracle_upd (
    a number(22),
    c varchar(100),
    primary key (a));

create table analysis_oracle_upd2 (
    a number(22),
    c varchar(100),
    primary key (a));

Upvotes: 0

Views: 598

Answers (1)

Guneli
Guneli

Reputation: 1731

You should add alias for table in your first subquery:

UPDATE analysis_oracle_upd t1
SET
  (c)
  =
  (SELECT t2.c FROM analysis_oracle_upd2 t2 WHERE t1.a = t2.a
  )
WHERE EXISTS
  (SELECT 1 FROM analysis_oracle_upd2 t2 WHERE t1.a=t2.a
  );

Upvotes: 2

Related Questions