oracle存储过程_2

[color=red]--1.判断语句[/color]
[color=blue]create or replace procedure [/color]test(x in number)
is
begin
if x>0 then
begin
x := 0-x;
end ;
end if;
if x=0 then
begin
x := 1;
end ;
end if;
end test;

[color=red]--for 循环 for ...in ..loop 执行语句 end loop
--(1) 循环遍历游标[/color]
[color=blue]create or replace procedure [/color]test() as
Cursor cursor is select name from student; name varchar2(20);
begin
for name in cursor loop
begin
dbms_output.put_line(name);
end;
end loop;
end test;
[color=red]
--while 循环 while 条件语句 loop begin end; end loop ;[/color]
[color=blue]create or replace procedure[/color] test(i in number) as
begin
while i<10 loop
begin
i:=i+1;
end;
end loop;
end test;

4.数组
oracel 数据库中没有数组的概念,数组其实是一张表,没个数组元素都是表中的一个记录。
使用数组的时候,用户可以使用oracle已经定义好的数组类型。或可以根据需要定义自己需要的数组类型。
(1) 使用oracle自带的数组类型:
x array ; 使用的时候需要初始化。
create or replace procedure test(y out array) is
x array ;
begin
x:=new array();
y:= x;
end test ;
(2) 自定义数组类型
create or replace package myPackage is
Public type declarations type
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值