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;
  • 相关阅读:
    5
    4
    3
    crontab -e 报错(E518: Unknown option: foldenable)
    解决无法修改日志时间的问题(Local time zone must be set--see zic manual page 2019 )
    ping测试丢包率
    关闭SELinux
    iotop使用方法
    mysql的备份
    修改uid gid 的起始范围
  • 原文地址:https://www.cnblogs.com/donghb/p/7382244.html
Copyright © 2011-2022 走看看