ORA-00933:SQL命令未正确结束-我缺少什么?

时间:2019-04-03 20:44:40

标签: sql oracle join sql-update

相当简单的更新...所以我想。我收到错误消息:ORA-00933:以下查询的SQL命令未正确结束。

我想念什么?

运行Oracle 12c

查询:

UPDATE P
SET    P.SERVICE_DATE_OUT = NULL,
       P.SERVICE_DATE_IN = NULL 
FROM   PMEQMT P 
       JOIN ARINVT A ON A.ITEMNO = P.EQNO
       JOIN FGMULTI F ON F.ARINVT_ID = A.ID
WHERE  P.SERVICE_DATE_OUT IS NOT NULL AND
       P.SERVICE_DATE_IN IS NOT NULL AND
       P.CLASS = 'TL' AND
       F.LOC_ID = 27354

2 个答案:

答案 0 :(得分:1)

您可以使用内联视图重写它:

df['C'].to_type('enum')

Oracle不支持UPDATE ( SELECT P.SERVICE_DATE_OUT, P.SERVICE_DATE_IN FROM PMEQMT P JOIN ARINVT A ON A.ITEMNO = P.EQNO JOIN FGMULTI F ON F.ARINVT_ID = A.ID WHERE P.SERVICE_DATE_OUT IS NOT NULL AND P.SERVICE_DATE_IN IS NOT NULL AND P.CLASS = 'TL' AND F.LOC_ID = 27354 ) s SET s.SERVICE_DATE_OUT = NULL, s.SERVICE_DATE_IN = NULL; 语法。

答案 1 :(得分:1)

或者(根据Lukasz的代码),查看类似的方法是否有帮助:

[编辑]

您说查询返回相同的错误。好吧,这不是-不适合我。

我已经创建了示例表(只是必要的列),运行了查询,并且-就语法而言是正确的。

SQL> create table pmeqmt (service_date_out date, service_date_in date, eqno number, class varchar2(2));

Table created.

SQL> create table arinvt (id number, itemno number);

Table created.

SQL> create table fgmulti (arinvt_id number, loc_id number);

Table created.

SQL>
SQL> update pmeqmt p set
  2    p.service_date_out = null,
  3    p.service_date_in = null
  4  where p.eqno in (select a.itemno
  5                   from arinvt a join fgmulti f on f.arinvt_id = a.id
  6                   where f.loc_id = 27354
  7                  )
  8    and p.service_date_out is not null
  9    and p.service_date_in is not null
 10    and p.class = 'TL';

0 rows updated.

SQL>