SQL解析失败,不知道问题出在哪里?

发布于 2024-12-18 07:38:25 字数 624 浏览 1 评论 0原文

这解析得很好:

MERGE INTO SECURE_GROUPS USING
    (SELECT :P94_NAME name FROM dual) data
ON (data.name = PEOPLE.PERSON_NAME)
WHEN NOT MATCHED THEN
    INSERT (PERSON_NAME) VALUES (data.name);

这失败了:

 MERGE INTO SECURE_GROUPS USING
        (SELECT :P94_NAME name, :P94_NUMBER num FROM dual) data
    ON (data.name = PEOPLE.PERSON_NAME)
    WHEN NOT MATCHED THEN
        INSERT (PERSON_NAME, PERSON_NUMBER) VALUES (data.name, data.num);

错误消息是:

发生了 1 个错误 ORA-06550:第 10 行,第 51 列:PL/SQL:ORA-00923:在预期位置未找到 FROM 关键字 ORA-06550:第 9 行,第 1 列:PL/SQL:忽略 SQL 语句

This parses fine:

MERGE INTO SECURE_GROUPS USING
    (SELECT :P94_NAME name FROM dual) data
ON (data.name = PEOPLE.PERSON_NAME)
WHEN NOT MATCHED THEN
    INSERT (PERSON_NAME) VALUES (data.name);

This fails:

 MERGE INTO SECURE_GROUPS USING
        (SELECT :P94_NAME name, :P94_NUMBER num FROM dual) data
    ON (data.name = PEOPLE.PERSON_NAME)
    WHEN NOT MATCHED THEN
        INSERT (PERSON_NAME, PERSON_NUMBER) VALUES (data.name, data.num);

The error message is:

1 error has occurred
ORA-06550: line 10, column 51: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 9, column 1: PL/SQL: SQL Statement ignored

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨落星ぅ辰 2024-12-25 07:38:25

我认为问题在于像您一样使用 PEOPLE.PERSON_NAME ,而不进行选择。尝试这样做:

MERGE INTO SECURE_GROUPS
    USING (
        select :P94_NAME name, :P94_NUMBER num from dual
    ) data
    ON (data.name in (select PERSON_NAME from PEOPLE))
    WHEN NOT MATCHED THEN
        INSERT (PERSON_NAME, PERSON_NUMBER) VALUES (data.name, data.num)

I think the issue is with using PEOPLE.PERSON_NAME like you are, without a select. Try doing it like this:

MERGE INTO SECURE_GROUPS
    USING (
        select :P94_NAME name, :P94_NUMBER num from dual
    ) data
    ON (data.name in (select PERSON_NAME from PEOPLE))
    WHEN NOT MATCHED THEN
        INSERT (PERSON_NAME, PERSON_NUMBER) VALUES (data.name, data.num)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文