zoukankan      html  css  js  c++  java
  • oracle 包和包实现

    包:

    create or replace package sp_pexam_clear
    as
        --定义结构体
        /*type re_stu is record(
            rname student.name%type,
            rage  student.age%type
        ); 
        --定义游标
        type c_stu is ref cursor; */
        --定义函数
        function numAdd(num1 number,num2 number)return number;
        --定义过程
        --procedure GetStuList(cid in varchar2);
    end;

    包实现:

    create or replace package body sp_pexam_clear as
      --游标和结构体,包规范中已声明,包体中不用再声明,直接使用。
    
      --实现方法
      function numAdd(num1 number, num2 number) return number as
        num number;
      begin
        num := num1 + num2;
        return num;
      end;
    
      --实现过程
      /*
      procedure GetStuList(cid varchar2) as
        r_stu re_stu; --直接使用包规范中的结构
      begin
        open c_st for
          select name, age from student where classid = cid;
        -- 如果已经在过程中遍历了游标,在使用这个过程的块中,将没有值。
        -- loop
        --     fetch c_st into r_stu;
        --     exit when c_st%notfounad;
        --     dbms_output.put_line('姓名='||r_stu.rname);
        -- end loop;
      end; */
    
    end;

    测试下:

    -- Created on 2016/7/12 by ACER 
    declare
      -- Local variables here
      i integer;
      num number ; 
    begin
      -- Test statements here
      --使用包中的方法
      select sp_pexam_clear.numAdd(5, 6) into num from dual;
      dbms_output.put_line('Num=' || num);
    end;
  • 相关阅读:
    LeetCode_4——寻找两个有序数组的中位数
    Java的CAS与ABA问题
    跨域问题解决
    解决git-for-windows官网下载速度慢的问题
    Java对观察者模式的支持
    Java动态代理
    设计模式七大原则
    UML中的类图关系
    布隆过滤器(Bloom Filter)与Hash算法
    Ubuntu16安装fabric1.4.4环境
  • 原文地址:https://www.cnblogs.com/lishupeng/p/5662364.html
Copyright © 2011-2022 走看看