错误(12,1):PL/SQL:语句被忽略错误(12,15):PLS-00405:在此上下文中不允许子查询

Posted

技术标签:

【中文标题】错误(12,1):PL/SQL:语句被忽略错误(12,15):PLS-00405:在此上下文中不允许子查询【英文标题】:Error(12,1): PL/SQL: Statement ignored Error(12,15): PLS-00405: subquery not allowed in this context 【发布时间】:2015-01-25 08:54:33 【问题描述】:

我在存储过程中编写了如下条件:

IF (ISBN_in IN (SELECT ISBN FROM ADD_BOOK))
/*Checking whether ISBN_in value exists in ADD_BOOK table or not*/
THEN

   UPDATE ADD_BOOK
   SET TITLE=TITLE_in,
   ADD_SUMMARY=Add_Summary_in,
   AUTHOR=Author_in,
   Published_Date=Published_Date_in,
   PAGE_COUNT=Page_Count_in 
   WHERE 
   ISBN=ISBN_IN;
   COMMIT;
END IF;

There, I'm seeing an error message as 

Error(12,1): PL/SQL: Statement ignored
Error(12,16): PLS-00405: subquery not allowed in this context

请多多指教。

谢谢,

【问题讨论】:

if (select count(column) from table) > 0 then 的可能重复项 【参考方案1】:

或者您可以完全删除 if 语句并尝试更新:

更新 add_book 放 ... WHERE isbn = isbn_in;

如果没有要更新的行,则不会发生任何事情。您还为自己节省了一次对表的额外调用,因此您的代码将具有更高的性能。

【讨论】:

以上是关于错误(12,1):PL/SQL:语句被忽略错误(12,15):PLS-00405:在此上下文中不允许子查询的主要内容,如果未能解决你的问题,请参考以下文章