开发PL/SQL子程序——过程


过程用于执行特定操作。如果应用程序经常需要执行特定操作,那么可以基于这些操作建立特定的过程,不仅可以简化客户端应用程序的开发和维护,而且可以提高应用程序的运行性能。


建立过程

例子:建立为雇员插入数据的过程:

create or replace procedure add_emp
(eno number,name varchar2,sal number,job varchar2 default 'CLERK',dno number)
is 
e_intergrity exception;
pragma exception_init(e_integrity,-2291);
begin 
insert into emp(empno,ename,sal,job,deptno)
valus(eno,name,sal,job,dno);
exception
when dup_val_on_index then
raise_application_error(-20000,'雇员号不能重复');
when e_integrity then
raise_application_error(-20001,'部门号不存在');
end;
/

删除过程

drop procedure add_emp;

显示过程代码

select text from user_source where name='ADD_EMP';

-------------------------------------------

作者:赵杰迪

-------------------------------------------

原文地址:https://www.cnblogs.com/zhaojiedi1992/p/oracle11g_sql_0019.html