0

I need you help in updating changes a table.

the table i want to update is IP_VISIT_EASTERN_REGION, the field I want to update is VISIT_STAT

so I wrote this query

UPDATE IP_VISIT_EASTERN_REGION SET
IP_VISIT_EASTERN_REGION.VISIT_STAT=TEST_IP_VISIT_EASTERN_REGION.VISIT_STAT
WHERE IP_VISIT_EASTERN_REGION.VISIT_ID = TEST_IP_VISIT_EASTERN_REGION.VISIT_ID

The Issue is I get an error

ORA-00904 INVALID IDENTIFIER 

and is this the correct way to do it.

your help will be really appreciated.

thank you

FatherofFaris
  • 41
  • 1
  • 5

1 Answers1

0

You can't write an UPDATE from a SELECT by using a join. Try this approach instead.

update set from inner join query thowing error

In your case:

UPDATE IP_VISIT_EASTERN_REGION REGION
SET REGION.VISIT_STAT= ( SELECT TEST.VISIT_STAT 
                         FROM TEST_IP_VISIT_EASTERN_REGION TEST
                         WHERE REGION.VISIT_ID = TEST.VISIT_ID )
WHERE EXISTS ( SELECT TEST.VISIT_STAT 
               FROM TEST_IP_VISIT_EASTERN_REGION TEST
               WHERE REGION.VISIT_ID = TEST.VISIT_ID );

Fiddle:

http://sqlfiddle.com/#!4/2178ae/1

Community
  • 1
  • 1
Drumbeg
  • 1,914
  • 1
  • 15
  • 22