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

SQLPlus执行含CREATE命令脚本异常:首COMMIT后停止并打印剩余代码

Troubleshooting SQLPlus Script Stopping After First COMMIT

First off, this issue is almost always tied to SQLPlus statement termination rules or script structure rather than database-level settings. Let’s break down the most common fixes and checks:

1. Fix PL/SQL CREATE Block Termination

If your CREATE commands are for stored procedures, functions, triggers, or packages (any multi-line PL/SQL block), you must terminate the block with a slash (/) on its own line before running COMMIT. SQLPlus uses this slash to execute the entire PL/SQL block—without it, it may not fully process the CREATE statement before moving to COMMIT, leading to unexpected execution stops.

Example of correct structure:

CREATE PROCEDURE sample_proc AS
BEGIN
  -- Procedure logic here
  NULL;
END;
/ -- Critical: Slash on a new line to execute the PL/SQL block
COMMIT;

CREATE TABLE sample_table (id NUMBER);
COMMIT; -- For table creation, a semicolon is sufficient

2. Execute the Script Properly

Avoid pasting the script content interactively into SQLPlus—terminal input buffering can cause premature execution stops. Instead, run the script using SQLPlus’s built-in commands:

sqlplus username/password@database @your_script.sql

3. Check for Hidden Control Characters

Scripts saved from some editors (like Windows Notepad) may have hidden carriage returns (\r) that confuse SQLPlus. Use a text editor that shows invisible characters, or run cat -v your_script.sql on Linux/macOS to spot these.

4. Rule Out Edge Case SQLPlus Settings

While less likely, a few settings could interfere with script execution:

  • SET STOPONERROR ON: This halts execution on errors, but since your first COMMIT completes, this is probably not the issue.
  • SET SQLTERMINATOR: If someone changed the default terminator from ; to another character, it could break statement parsing. Check with SHOW SQLTERMINATOR and reset to default with SET SQLTERMINATOR ; if needed.

If none of these work, simplify your script to a minimal version (two CREATE commands + COMMITs) to isolate the problem, then add back sections until you find the line causing the stop.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 07:14:53