建立包规范 create or replace package emp_package is g_deptno number(3):=30; procedure add_employee(eno number
begin select sal into v_sal from emp where empno=eno; return v_sal;exception when no_data_found then RAISE_ApPLICATION_ERROR(-20012,'该雇员不存在');end get_sal;end emp_package;
调用包组件
1.在同一个包内调用
procedure add_employee(eno numberk,ename varchar2,salary number,dno number default g_deptno)isbegin if validate_deptno(dno)then insert into emp(empno,ename,sal,deptno)values(eno,ename,salary,dno); else raise_application_error(-20010,'不存在该部门'); end if;exception when dup_val_on_index then raise_application_error(-20011,'该雇员已存在');end;
2.调用公用变量
3.调用公用过程
4.调用公用函数
----当使用其他用户身份调用公用组件时,,必须在组件名前加用户名和包名作为前缀
----SCOTT.EMP_PACKAGE.。。。。
----当调用远程数据库包的公用组件是,在组件名前加包名作为前缀在组件名后需要带有数据库链名作为后缀
----EMP_PACKAGE.ADD_EMPLOYEE@TENDER(1111,'SCOTT',1233,10)
----查看源代码
----select text from user_source whereand type='package'
本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉
本文系统来源:php中文网