plsql基础语法
来源:互联网 发布:东莞 体验 全套 知乎 编辑:程序博客网 时间:2024/05/16 04:55
--while循环
declare num1 number;
begin
num1:=1;
while num1=1 loop
dbms_output.put_line(to_char(num1));
num1:=2;
end loop;
end;
--if.....else
declare num2 number;
begin
num2:=3;
if num2=2 then
dbms_output.put_line('if success');
else
dbms_output.put_line('else success');
end if;
end;
--if....else if....else
declare num3 number;
begin
num3:=3;
if num3=2 then
dbms_output.put_line('if success');
elsif num3=3 then
dbms_output.put_line('if..else success');
else
dbms_output.put_line('else success');
end if;
end;
--case的用法
declare num4 number;
begin
num4:=4;
case num4
when 1 then dbms_output.put_line('num4=1');
when 2 then dbms_output.put_line('num4=2');
when 3 then dbms_output.put_line('num4=3');
when 4 then dbms_output.put_line('num4=4');
else dbms_output.put_line('num4=无限大');
end case;
end;
--loop end 循环
declare
x number;
begin
x := 0;
loop
x:=x+1;
dbms_output.put_line(to_char(x));
exit when x = 10;
end loop;
end;
--for循环
begin
for i in reverse 1..10
loop
dbms_output.put_line('i='||i);
end loop;
end;
显式光标处理需四个 PL/SQL步骤:
cursor 光标名称 is select 语句;
open 光标名称;
Fetch 光标名称 into 变量列表;
Close 光标名称;
declare
cursor get_well is select well_id,well_common_name from cd_well_source where rownum<5;
wellId varchar2(50);
wellCommonName varchar2(50);
begin
open get_well;
fetch get_well into wellId,wellCommonName;
while get_well%found
loop
dbms_output.put_line(wellCommonName);
fetch get_well into wellId,wellCommonName;
end loop;
close get_well;
end;
- PLsql基础语法
- PLsql基础语法
- plsql基础语法
- PLSQL语法基础
- plsql基础函数语法
- PLSQL 编程基础语法要点
- plsql 语法
- PLSQL语法
- PLSQL语法
- PLSQL基础
- plsql编程语法
- plsql常用语法
- PLSQL基本语法
- PLSQL语法小结
- Oracle PLSQL语法
- PLSQL—SQL语法参考手册
- PLSQL的书写及语法
- PLSQL的书写及语法
- Ext资源
- 新手进军中
- hdu1233还是畅通工程
- 同步/异步与阻塞/非阻塞的区别
- 【小结】初学Zend_Db_Table Relationships
- plsql基础语法
- selenium配置firefox profile, 创建firefox profile
- setsocket用法大全(转自CSDN之gdy网友之作)
- simpletree学习笔记
- pku 1703 Find them, Catch them
- 昨天看了《唐山大地震》
- Apache配置虚拟机
- simple tree 学习笔记2
- 模板方法模式