ITPub博客

首页 > Linux操作系统 > Linux操作系统 > How to rename an Oracle stored procedure

How to rename an Oracle stored procedure

原创 Linux操作系统 作者:lwitpub 时间:2011-08-30 20:05:00 0 删除 编辑

Is there a way to rename an oracle stored procedure, without having to drop and recreate the procedure?

You can effectively rename a stored procedure by simply creating another procedure - with the new name - that simply calls the old procedure. Here is an example.

create or replace procedure new_procedure_name(variables in type)
as
begin
old_procedure_name(variables in type);
end;
/

[oracle@rh4racdb01 gary]$ cat demo.sql
create or replace procedure test_sql(aa in char)
as
begin
delete from emp where empno=10000;
commit;
end;
/
[oracle@rh4racdb01 gary]$ cat demo_rename.sql
create or replace procedure test_sql_old(bb in varchar2)
as
begin
test_sql(bb);
end;
/
scott@RACDB>@demo.sql

Procedure created.

scott@RACDB>@demo_rename.sql

Procedure created.

scott@RACDB>select object_name,OBJECT_TYPE from user_procedures;

OBJECT_NAME                             OBJECT_TYPE
------------------------------------------------------------ -------------------
TEST_SQL                                      PROCEDURE
TEST_SQL_OLD                             PROCEDURE

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/628922/viewspace-706279/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-05-08

  • 博文量
    107
  • 访问量
    418836