Oracle 19c存储包编译错误排查求助
Hey there, let's break down the issues in your scripts causing those compilation errors, plus address your question about COMMIT statements:
1. 直接触发编译失败的语法错误
Take a close look at your package body definition line:
create or replace PACKAGE BODY PNM_WS_ADS_CONTRACT_ENTITIES "PNM_WS_ADS_CONTRACT_ENTITIES" AS
You’ve duplicated the package body name in quotes right after the first valid declaration—this is invalid Oracle syntax. The correct syntax only requires the package name once, with no extra quoted version. Remove that trailing "PNM_WS_ADS_CONTRACT_ENTITIES" and this critical syntax issue will be fixed immediately.
2. 关于COMMIT语句的疑问
You’re correct that COMMIT is intended for DML operations (INSERT/UPDATE/DELETE), but for DDL operations like creating or replacing packages, Oracle automatically runs an implicit COMMIT before and after the DDL executes. So adding explicit COMMIT; after your package definitions is completely unnecessary—but it won’t cause compilation errors either. It’s just redundant, not a root cause here.
3. 其他需要注意的小问题(不影响编译,但可能引发运行异常)
- In your
GET_INFOprocedure, when you open the cursor forSELECT 1 FROM DUAL, you never explicitly close it. While Oracle will auto-close cursors when the procedure exits, it’s better practice to manage cursor lifecycle explicitly for clarity. - In the
GET_NETWORKSprocedure’s SELECT query, you haveCONT.IN_PATIENT_RATElisted twice. This won’t break compilation, but it will result in duplicate columns in your ref cursor output, which might confuse the code calling this procedure. - There’s a typo in your error message:
INAVALID REQUESTshould beINVALID REQUEST—this is a runtime message issue, not a compilation error.
Fix that package body name duplication first, and that should resolve the "created with compilation errors" warning. If you still have issues after that, run SHOW ERRORS PACKAGE BODY PNM_WS_ADS_CONTRACT_ENTITIES; in SQL*Plus or your Oracle tool to get exact error details, which will help pinpoint any remaining problems.
备注:内容来源于stack exchange,提问作者public_void_kee

