scalar subquery in if statement Condition in PL/SQL

寵の児 提交于 2019-12-02 01:27:27

No, you can't use a SELECT in the way you want.

In your example using CASE, you are not using a CASE "statement" -- you are using a CASE expression, which happens to be embedded within a SQL statement. You can use a subquery in that case because it's within the context of a SQL statement, not a procedural statement. You wouldn't be able to use a subquery like this in a procedural CASE statement.

Have you called DBMS_OUTPUT.ENABLE

Quick example

BEGIN
DBMS_OUTPUT.DISABLE;
DBMS_OUTPUT.PUT_LINE('Disabled');
DBMS_OUTPUT.ENABLE;
DBMS_OUTPUT.PUT_LINE('Enabled');
END;

I don't believe subqueries are supported in IF conditions... PL/SQL will be expecting the SELECT to give it a set of records, not a single value to be used in a expression/statement.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!