zoukankan      html  css  js  c++  java
  • oracle--知识点汇总2---laobai

    --复制表
    create table emp as(select * from scott.emp);
    select * from emp;
    --Demo1创建存储过程,实现将emp表comm为空时,替换成0
    create or replace procedure update_emp_comm as
    begin
    update emp set comm='1' where comm='0';
    dbms_output.put_line('替换成功!');
    commit;
    end;
    --创建有入参及有出参的存储过程
           --修改指定部门的员工工资,+100,将修改的条数作为出参
    create or replace procedure update_emp_sal_by_deptno
    (
    v_deptno number,
    v_sal number,
    v_rowcount out number
    )
    as
    begin
    update emp set sal=sal+v_sal where deptno=v_deptno;
    dbms_output.put_line('修改成功,共修改了'||sql%rowcount||'条记录');
    v_rowcount:=sql%rowcount;
    commit;
    end;
    --创建函数,返回值
      --删除含有指定名称的员工,返回删除的条数
    create or replace function delete_emp_by_empname
    (
    v_name varchar2
    )return number
    as
    v_num number;
    begin
    delete from emp where ename like '%'||v_name||'%';
    v_num:=sql%rowcount;
    commit;
    return v_num;
    end;
    --创建函数,返回指定结果集的游标
     --统计人数超过5个人的部门的最高工资和最低工资
    create or replace function get_max_min_sal_by_group
    return sys_refcursor
    as 
    my_cur sys_refcursor;  --声明1个游标变量,用于返回
    begin
    open my_cur for
    select deptno 部门号,max(sal) 最高工资,min(sal) 最低工资 from emp group by deptno having count(1)>3;
    return my_cur;
    end;
    

      

  • 相关阅读:
    设计模式系列
    设计模式系列
    设计模式系列- 抽象工厂模式
    设计模式系列
    Python3 系列之 编程规范篇
    【ABAP系列】SAP ABAP BDC_OKCODE 解释
    【ABAP系列】SAP ABAP MIR7预制凭证BAPI
    【ABAP系列】SAP ABAP 的替代和校验
    【ABAP系列】SAP ABAP 开发中的SMARTFORMS 参数
    【ABAP系列】SAP ABAP 实现FTP的文件上传与下载
  • 原文地址:https://www.cnblogs.com/ipetergo/p/6251021.html
Copyright © 2011-2022 走看看