zoukankan      html  css  js  c++  java
  • Oracle 存储过程--01

    1.简单的例子

    /*
    1.求圆的面积
    */
    create or replace procedure proc_1 is
      pi constant number(9,7):=3.1415927;
      radius integer(5);
      area number(14,2);
    begin
      radius:=3;
      area:= pi*power(radius,2);
      insert into areas values(radius,area);
    end proc_1;
    

    2.使用游标,loop循环

    /*
    2.从表中读取值,计算圆的面积
    */
    create or replace procedure proc_2 is
      pi constant number(9,7) := 3.1415927;
      area number(14,2);
      cursor rad_cur is 
           select * from radius_vals ;
      rad_temp rad_cur%rowtype;
    begin
      open rad_cur;
      loop
           fetch rad_cur into rad_temp;
           exit when rad_cur%notfound;
           area:=pi*power(rad_temp.radius,2);
           insert into areas values(rad_temp.radius,area);
      end loop;
      close rad_cur;
    end proc_2;
    

    3.for循环

    /*
    3.for循环
    */
    create or replace procedure proc_3 is
    pi constant number(9,7):= 3.1415625;
    cursor rad_cur is 
           select * from  radius_vals;
    area number(14,2);
    begin
      for rad_val in rad_cur
      loop
          area:=pi*power(rad_val.radius,2);
          insert into areas values(rad_val.radius,area);
      end loop;
    end proc_3;

     

  • 相关阅读:
    excel unixtime与北京时间互转
    vim的漫漫长征路
    const常量
    第一章:绪论
    2.4奇偶校验
    2.3数据校验的基本原理
    2.2定点与浮点数据表示
    2.1机器数及其特点
    1.2计算机系统性能评价
    冯诺依曼结构原理及层次分析
  • 原文地址:https://www.cnblogs.com/jycjy/p/11358027.html
Copyright © 2011-2022 走看看