标签:定义 seq 语句 number 一个 roc sel var 直接
package是由一个或多个porcedure/function组成的。
定义:
create or replace package 包名
is
procedure/function定义部分;--以分号作为间隔
end;
/
create or replace package body 包名
is
procedure/function开始到end结束;--以分号作为间隔
/
例如:
create or replace package user_pack
is
procedure addUser
(
useCode in number default user_seq.nextval,
user_name in varchar2 default ‘小明‘,
age in number default 20,
user_birth_day in date default sysdate,
apple in number default 3
);
function getApple(userCode number)
return number;
end;
/
create or replace package body user_pack
is
procedure addUser
(
useCode in number default user_seq.nextval,
user_name in varchar2 default ‘小明‘,
age in number default 20,
user_birth_day in date default sysdate,
apple in number default 3
)
is
begin
select apple into apple from t_user where user_code=userCode;
end;
function getApple(userCode number)
return number
is
apple number;
begin
select apple into apple from t_user where user_code=userCode;
return apple;
end;
/
查看package:desc user_pack;
调用package中的procedure/function:exec user_pack.getApple(3);
desc dbms_output;
查看package定义语句:select text from user_source where name=‘USER_PACK‘;
package body定义语句加密:
创建文件user_pack.sql,将package body定义语句复制到此文件中,
执行:wrap iname=user_pack.sql
执行后会生成一个user_pack.plb的文件,即加密后的文件
创建package body时,直接执行:@user_pack.plb
标签:定义 seq 语句 number 一个 roc sel var 直接
原文地址:https://www.cnblogs.com/cyf18/p/10765582.html