【问题标题】:SQL Error: ORA-00933: SQL command not properly ended: Postgres to oracle syntaxSQL 错误:ORA-00933:SQL 命令未正确结束:Postgres 到 oracle 语法
【发布时间】:2013-02-02 04:40:34
【问题描述】:

我收到以下语句的 SQL 错误 ORA-00933。这在 postgres 中解析,但在 oracle 中不解析...应该如何为 oracle 格式化?

提前致谢!

UPDATE comments 
SET parent_type='report' 
FROM reports 
WHERE comments.parent_id=reports.id;

【问题讨论】:

标签: sql database oracle postgresql


【解决方案1】:

在 Oracle 上试试这个:

UPDATE Comments
SET parent_type = 'report'
WHERE parent_id IN (SELECT Id FROM Reports)

或者,如果您尝试将值设置为等于另一列中的值:

UPDATE Comments
SET parent_type = (SELECT FieldName
                   FROM reports
                   WHERE reports.id = Comments.parent_id);

这适用于 MSSQL:

UPDATE c
SET c.parent_type='report' 
FROM Comments c JOIN reports r ON c.parent_id=r.id

祝你好运。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-15
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 2012-02-14
    • 1970-01-01
    相关资源
    最近更新 更多