Oracle 命令在数据库中有效但在 SQLPlus 中无效

Oracle command works in database but not in SQLPlus

我目前正在尝试实施一个 bash 脚本,该脚本 运行 在一天结束时 运行 是一个简单的 oracle 查询。该命令在 Oracle 中运行良好,但在 .sql 文件中时它不会 运行.

我试图将所有代码放在一行中并添加分号。


批处理文件的内容(更改了 user/pass):

sqlplus username/password@database @set_changed.sql

set_changed.sql 文件的内容:

UPDATE ris_web a
SET a.changed = 0
where exists
(
    select modified_date from invn_sbs b
    where b.item_sid = a.item_sid
        and b.modified_date <= sysdate-1
);
COMMIT;
END;

在 SQLPlus 中,您应该在单独的行上使用 / 来终止 SQL 语句或 PL/SQL 块,而不是使用分号,因此请更改您的归档到

UPDATE ris_web a
SET a.changed = 0
where exists
(
    select modified_date from invn_sbs b
    where b.item_sid = a.item_sid
        and b.modified_date <= sysdate-1
)
/

SHOW ERRORS
/

COMMIT
/

SHOW ERRORS
/

END

You might also want to have a look at this question

脚本末尾有 end; 命令,但没有 BEGIN 命令。

只需将 END; 替换为 /

原来的语法是正确的。 sqldeveloper 中有未提交的更改导致 .sql 文件永远无法完成 运行。感谢大家的帮助。