Skip to Main Content
  • Questions
  • SQL Statement ORA-00936: missing expression

Breadcrumb

May 4th

Question and Answer

Chris Saxon

Thanks for the question, Stefanie.

Asked: September 09, 2016 - 8:22 am UTC

Last updated: March 17, 2022 - 1:49 pm UTC

Version: Oracle 11.2.04

Viewed 100K+ times! This question is

You Asked

Hi Tom,

What is wrong with this statement? I want to initiate an initialexport from a certain category of persons.

UPDATE planung
SET dienstposition = dienstposition
WHERE (planung.datum between '2016-01-01' AND '2016-01-02')
AND (select planung.mitarbeiter_id FROM planung
INNER JOIN mitarbeiter ON planung.mitarbeiter_id = mitarbeiter.id where mitarbeiter.personalnummer IN ('735582'));


Update-Statement (ORA-00936-Error) missing expression

Maybe you have an idea?

Best
Stefanie

and Chris said...

The subquery isn't joined to anything!

and (select planung.mitarbeiter_id
 from planung
 inner join mitarbeiter
 on planung.mitarbeiter_id         = mitarbeiter.id
 where mitarbeiter.personalnummer in ( '735582' ) ) ;


You need to compare this to something (=, <>, <=, whatever). e.g.:

and (select planung.mitarbeiter_id
 from planung
 inner join mitarbeiter
 on planung.mitarbeiter_id         = mitarbeiter.id
 where mitarbeiter.personalnummer in ( '735582' ) )  = ...;


Or if you're just checking there is a row, use an exists:

and exists (select planung.mitarbeiter_id
 from planung
 inner join mitarbeiter
 on planung.mitarbeiter_id         = mitarbeiter.id
 where mitarbeiter.personalnummer in ( '735582' ) ) ;

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Pointless Update

Alex Nuijten, March 16, 2022 - 10:21 am UTC

Probably this needs to change as well, otherwise you're just updating to the value that it already has...

SET dienstposition = dienstposition

Chris Saxon
March 17, 2022 - 1:49 pm UTC

Good point!