剑轩

Oracle程序包

电脑版发表于:2018/12/29 13:58

当项目越来越大的时候,数据库中的函数,存储过程等越来越多。为了方便管理,Oracle建议使用程序包的管理机制。

实现业务模块隔离,方便管理。类似与c#的名称空间


Oracle程序包主要分为包头与包体。


创建一个Oracle包头

主要就是函数,存储过程等的申明

create or replace package mypackage
as
  function func_sum(a int,b int) return int;
  procedure proc_show;
end mypackage;


创建一个Oracle包体

包体就是函数,存储过程等的具体实现了

create or replace package body mypackage 
as
 function func_sum(a int,b int)
 return int
 is
 begin
     return a+b;
 end;   
    
 procedure proc_show
 as
 begin
    dbms_output.put_line('hello package');
 end;  
 
end mypackage;


执行

和简单就是包名+函数,存储过程等的名字就好了

begin
   mypackage.proc_show();
end;

执行结果:







关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢