• PL/SQL实例1


    declare
    --定义游标
        cursor cemp is select to_char(hiredate,'yyyy') from emp;
        phiredate varchar2(4);
        --定义每年入职的人数
        count80 number:=0;
        count81 number:=0;
        count82 number:=0;
        count87 number:=0;
        begin
          --打开光标
          open cemp;
          --循环
         loop
           --取一个员工的入职年份
           fetch  cemp into phiredate;
           --定义循环出口
            exit when cemp%notfound;
            --if判断
            if phiredate='1980' then  count80:=count80+1;
            elsif phiredate='1981' then  count81:=count81+1;
            elsif phiredate='1982' then count82:=count82+1;
            else count87:=count87+1;
            end if;

    --结束循环
          end loop;
          --关闭游标
          close cemp;
          --输出
           dbms_output.put_line('total:'||(count80+count81+count82+count87));
           dbms_output.put_line('1980:'||count80);
           dbms_output.put_line('1981:'||count81);
           dbms_output.put_line('1982:'||count82);
           dbms_output.put_line('1987:'||count87);
          end;

  • 相关阅读:
    UIPickerView-一.01-
    闭包-01-Swift
    Swift 入门-01-概述
    git使用命令行-01-自己操作的
    FetchedResultsController-03-CoreData相关
    SQLite-05-增删改查
    Sqlite函数总结-04
    List<string>转xml
    比较两个List<T>是否相同
    获取DataTable前几条数据
  • 原文地址:https://www.cnblogs.com/newcityboy/p/11979896.html
Copyright © 2020-2023  润新知