zoukankan      html  css  js  c++  java
  • [跟着hsp步步学习系统]oracle培训学习集锦全360度扫描(7) ifelse及loop end loop的使用

    第三十七讲
    if then
    if else then 
    if else then elsif elsif
    create or replace procedure pro1(v_in_ename varchar2) is
    --定义工资变量
    v_sal emp.sal%type;
    begin
    select sal into v_sal from emp where ename=发——沁+;
    if v_sal<2000 then
    update emp set sal=sal*1.1 where ename=v+in+ename;
    end if;
    end;


    第二个例子 if then else
    create or replace procedure pro2(v_in_ename varchar) is
    v_com emp.com%type;
    begin
    select comm into v_comm from emp where ename=v_in_ename;
    if v_comm<>0 then
    update emp set comm=comm+100 where ename=v_in_ename;
    else 
    update emp set comm=200 where ename=v_in_ename;
    end if;
    end;
    特别说明一下,字符串比较是一个等号
    2.循环语句loop  ....end loop先执行后退出
    loop
    ..
    exit when 条件表示式
    end loop;
    说明 这里的条件表达式如果为true,则继续执行
    create table users(
    id number primary key,
    name varchar2(42)
    )
    create or replace procedure pro1(v_in_name varchar,n number) is
    --定义变量
    v_empno number:=1;
    begin
    --exit when n<=0;
    loop
    --执行添加任务


    insert into users values(v_empno,v_in_name);
    exit when v_empno=n;
    --v_empno自己增加一下
    v_empno:=v_empno+1;
    end loop;
    end;

  • 相关阅读:
    javajava.lang.reflect.Array
    基于annotation的spring注入
    jquery插件
    spring的注入方式
    jqueryajax
    javascript基础
    xml基础
    js 获取FCKeditor 值
    TSQL 解析xml
    Linq
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3006984.html
Copyright © 2011-2022 走看看