zoukankan      html  css  js  c++  java
  • 隐式游标与程序包

    隐式游标
              sql游标
                     insert
                     delete
                     update
                     select(返回单行记录的查询)
    引用游标类型
              type stucursor is ref cursor;
    程序包和程序包体
              create or replace package pname as
                          procedure p1(b in varchar2);
                          function f1(a in number);
              end pname;

              create or replace package body pbname as
                          procedure p1(b varchar2) as
                          begin
                                  dbms_output.put_line(123);
                          end;
              end pbname;

    隐式游标:

    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;

    构建程序包:

    --构建程序包
    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;

    调用程序包

    --调用程序包存储过程
    Declare 
      i Integer;
      --引用游标
      Type stuc Is Ref Cursor;
      sts 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;
  • 相关阅读:
    mixin混合
    python类内部调用自己的成员函数必须加self
    合并/取消合并单元格
    pandas 显示所有的行和列
    pandas 利用openpyxl设置表格样式
    Nowcoder9983G.糖果(并查集)
    Nowcoder9983F.匹配串(思维)
    Nowcoder9983E.买礼物(链表+线段树)
    Nowcoder9983C.重力追击(暴力+少用sqrt)
    Nowcoder9983B.内卷(双指针)
  • 原文地址:https://www.cnblogs.com/jgjk/p/7388900.html
Copyright © 2011-2022 走看看