oracle 更改过程包和包体 PL/SQL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8988061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:33:36  来源:igfitidea点击:

Alter Procedure Package and Package Body PL/SQL

oraclestored-proceduresplsqloracle11g

提问by radu florescu

I want to make an incremetal script for my oracle database. I want to modify only one procedure signature and it's body and the rest should remain the same.

我想为我的 oracle 数据库制作一个增量脚本。我只想修改一个过程签名,它的主体,其余的应该保持不变。

How can I accomplish this without recreating the hole package with create or replace?

如何在不使用创建或替换重新创建孔包的情况下完成此操作?



Example

例子

Old package

旧包

PROCEDURE LOAD_ITEMS(OUTCURSOR OUT SYS_REFCURSOR);

New package

新包

PROCEDURE LOAD_ITEMS(P_ID IN CHAR, OUTCURSOR OUT SYS_REFCURSOR);


Edit:
By incremental script, I mean upgrade script from previous version to this one. And I want to modify only the current procedure, NOT ALL OF THEM.

编辑:
增量脚本,我的意思是从以前的版本升级到这个版本的脚本。而且我只想修改当前程序,而不是全部。

回答by Peter Lang

If you want to change a procedure in the package specification, then you need to
CREATE OR REPLACE
the whole package specification and body with the changed code.

如果要更改包规范中的过程,则需要
CREATE OR REPLACE
使用更改后的代码更改整个包规范和主体。



While the ALTER PACKAGEstatement can be used to recompile the whole package, it

虽然该ALTER PACKAGE语句可用于重新编译整个包,但它

[...] does not change the declaration or definition of an existing package. To redeclare or redefine a package, use the CREATE PACKAGEor the CREATE PACKAGE BODYstatement with the OR REPLACEclause.

[...] 不会更改现有包的声明或定义。要重新声明或重新定义包,请使用CREATE PACKAGEorCREATE PACKAGE BODY语句和OR REPLACE子句。