zoukankan      html  css  js  c++  java
  • oracle构造过程实例

      包的构造过程是没有任何名称的,它是在实现了包的其他过程之后,以begin开始,以end结束的部分。

    1,包头

    create or replace package pkg_emp is
      minsal number(6, 2);
      maxsal number(6, 2);
      procedure add_employee(eno    number,
                             name   varchar2,
                             salary number,
                             dno    number);
      procedure upd_sal(eno number, salary number);
      procedure upd_sal(name varchar2, salary number);
    end pkg_emp;

    2,包体

    create or replace package body pkg_emp is

      procedure add_employee(eno    number,
                             name   varchar2,
                             salary number,
                             dno    number) is
      begin
        if salary between minsal and maxsal then
          insert into emp
            (empno, ename, sal, deptno)
          values
            (eno, name, salary, dno);
        else
          raise_application_error(-20001, '工资不在范围内');
        end if;
      exception
        when dup_val_on_index then
          raise_application_error(-20002, '该雇员已经存在');
      end;

      procedure upd_sal(eno number, salary number) is
      begin
        if salary between minsal and maxsal then
          update emp set sal = salary where empno = eno;
          if sql%notfound then
            raise_application_error(-20003, '不存在该雇员号');
          end if;
        else
          raise_application_error(-20001, '工资不在范围内');
        end if;
      end;

      procedure upd_sal(name varchar2, salary number) is
      begin
        if salary between minsal and maxsal then
          update emp set sal = salary where upper(ename) = upper(name);
          if sql%notfound then
            raise_application_error(-20004, '不存在该雇员号');
          end if;
        else
          raise_application_error(-20001, '工资不在范围内');
        end if;
      end;
     
    --构造过程
    begin
      select min(sal), max(sal) into minsal, maxsal from emp;
    end;

  • 相关阅读:
    React源码 Suspense 和 ReactLazy
    React源码 ReactContext
    BZOJ 3456: 城市规划 与 多项式求逆算法介绍(多项式求逆, dp)
    LOJ #6436. 「PKUSC2018」神仙的游戏(字符串+NTT)
    LOJ #6433. 「PKUSC2018」最大前缀和(状压dp)
    LOJ #6432. 「PKUSC2018」真实排名(组合数)
    LOJ #2542. 「PKUWC 2018」随机游走(最值反演 + 树上期望dp + FMT)
    LOJ #2541. 「PKUWC 2018」猎人杀(容斥 , 期望dp , NTT优化)
    LOJ #2540. 「PKUWC 2018」随机算法(概率dp)
    LOJ #2538. 「PKUWC 2018」Slay the Spire (期望dp)
  • 原文地址:https://www.cnblogs.com/alang85/p/2140774.html
Copyright © 2011-2022 走看看