You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SQL Developer中如何屏蔽PL/SQL执行成功提示避免误导?

How to Remove the "PL/SQL procedure successfully completed." Message in SQL Developer

Great question—this is a super common gotcha with SQL Developer, especially when you’re relying on DBMS_OUTPUT for error alerts but that success message keeps throwing you off. Here are a few reliable ways to fix it:

  • Use Exception Handling to Fail Intentionally
    The root issue is that even if you print an error via DBMS_OUTPUT, the PL/SQL block still finishes "successfully" unless you explicitly tell it to fail. By raising an exception when your logic detects a problem, you’ll replace that misleading success prompt with an actual error notification.

    Example code:

    DECLARE
      v_error_details VARCHAR2(500);
    BEGIN
      -- Your core logic goes here
      IF <your_error_condition> THEN
        v_error_details := 'Error: Invalid input for customer ID';
        DBMS_OUTPUT.PUT_LINE(v_error_details);
        -- Throw a custom application error (valid range: -20000 to -20999)
        RAISE_APPLICATION_ERROR(-20001, v_error_details);
      END IF;
    
      -- If no issues, run your normal operations
      DBMS_OUTPUT.PUT_LINE('Process finished correctly');
    EXCEPTION
      WHEN OTHERS THEN
        -- Optional: Log unexpected errors before re-throwing
        DBMS_OUTPUT.PUT_LINE('Unexpected failure: ' || SQLERRM);
        RAISE; -- Re-throw the error so SQL Developer shows it as a failure
    END;
    /
    

    When an exception is raised, SQL Developer will display the error message instead of the success prompt, eliminating confusion entirely.

  • Suppress Feedback with SQL*Plus Commands
    SQL Developer supports most SQL*Plus commands, including SET FEEDBACK OFF, which turns off the "successfully completed" message (along with other feedback like row counts from SELECT statements).

    Add this line at the top of your script:

    SET FEEDBACK OFF
    

    This setting applies to your entire session, so if you need feedback for other operations later, you can toggle it back on with SET FEEDBACK ON.

  • Use "Run Script" for Combined Output (Partial Workaround)
    If you use the "Run Script" option (F5) instead of "Run Statement" (Ctrl+Enter), the success message will appear in the same Script Output tab as your DBMS_OUTPUT messages. While this doesn’t remove the message, it keeps all output in one place, making it far less likely you’ll miss error alerts hidden in the output.


内容的提问来源于stack exchange,提问作者TomB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:53:01