zoukankan      html  css  js  c++  java
  • 构建程序包、

    --构建程序包
    create or replace package stuinfo as
           type stucur is ref cursor;
           procedure showname(scla in number,stus out stucur);
    end stuinfo;
    --构建程序包体
    create or replace package body stuinfo as 
           procedure showname(scla in number,stus out stucur) as 
             begin 
               open stus for select * from student s where s.class = scla;
             end; 
    end stuinfo;
    select * from student;

    隐式游标

    DECLARE
    
    BEGIN
    /*
    insert
    update
    delete
    select(返回单行的查询)
    */
      UPDATE STUDENT S SET S.SBIRTHDAY = S.SBIRTHDAY + 3650 WHERE s.class=95031;
      IF SQL%FOUND THEN
        DBMS_OUTPUT.PUT_LINE('数据更新成功 !');
        DBMS_OUTPUT.PUT_LINE(sql%ROWCOUNT);
        COMMIT;
      ELSE
        DBMS_OUTPUT.PUT_LINE('更新失败 !');
      END IF;
    END;

    调用程序包执行存储过程

    -- 调用程序包执行存储过程
    declare 
    
      type stuc is ref cursor; --stuc引用游标
      sts stuc;--声明stuc类型的变量
      stu student%rowtype; --每一行查询
      
    begin
      stuinfo.showname(95033,sts);
      loop
        fetch sts
              into stu;
        exit when sts%notfound;
        dbms_output.put_line(stu.sname);
      end loop;
      
    end;
  • 相关阅读:
    链接收藏:bullet物理引擎不完全指南
    设计模式的六大原则
    链接错误 2038
    玄天宝录
    第二章 期中架构
    第一章 Linux基础
    13 代理与负载均衡基础
    12 LNMP搭建
    11 搭建博客
    10 Nginx模块介绍
  • 原文地址:https://www.cnblogs.com/donghb/p/7382244.html
Copyright © 2011-2022 走看看