过程化的sql
变量的定义
变量名 数据类型 初始值表达式
变量赋值
变量名:=表达式
流程控制
if condition then
.....
else
.....
end if ;
loop
.....
end loop ;
while condition loop
......
end loop ;
for count in bound1 .. bound2 loop
......
end loop ;
for item in [reverse] loop
.....
end loop ;
实例
create or replace function func_name(arg1 int,arg2 int)
as
declare
a int ;
b int ;
begin
end ;
call func_name(arg1,arg2)
-------------------------------------------------------------------
declare
num number := 1;
item varchar2(100);
begin
while num <= 5
loop
SELECT sys_guid() into item FROM dual ;
num := num + 1;
dbms_output.put_line(item);
end loop;
end;
----------
declare a varchar(32);
cursor cc is
select no from student ;
begin
open cc ;
fetch cc into a ;
while cc%found loop
dbms_output.put_line('序号'||a);
fetch cc into a ;
end loop ;
end ;