[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
[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