六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 95|回复: 0

ORACLE 学习笔记(一)

[复制链接]

升级  50%

5

主题

5

主题

5

主题

童生

Rank: 1

积分
25
 楼主| 发表于 2013-2-5 01:21:48 | 显示全部楼层 |阅读模式
觉得应该好好总结一下,ORACLE之PL/SQL学习
begin
if ... then
...
elsif ...then
...
end if;
end;
实例:
DECLAREa number;b varchar2(10);begina:=2;if a=1 thenb:='a';elsif a=2 thenb:='b';elseb:='c';end if;DBMS_OUTPUT.PUT_LINE('b is'||b);end;/有关case when
case
when.. then...
when.. then...
end case
实例
DECLAREa number;b varchar2(10);begina:=2;case when a=1 then b:='a';when a=2 then b:='b';when a=3 then b:='c';elseb:='others';end case;DBMS_OUTPUT.PUT_LINE('b is'||b);end;/
循环语句
LOOP
...
END LOOP

WHILE expression LOOP
...
END LOOP

FOR counter in[REVERSE] start_value..end_value LOOP
...
END LOOP;

实例(用第一种方式)
declarex number;beginx:=0;loopx:=x+1;if x>=3 thenexit;end if;dbms_output.put_line('内:x='||x);end loop;dbms_output.put_line('外:x='||x);end;/用exit when方式
declarex number;beginx:=0;loopx:=x+1;exit when x>=3;dbms_output.put_line('内:x='||x);end loop;dbms_output.put_line('外:x='||x);end;/用第三种方式,注意这是reverse的俄,如果是1 to 5,就不加reverse
beginfor i in reverse 1..5  loopdbms_output.put_line('i='||i);end loop;dbms_output.put_line('end of for loop');end;/
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表