1、创建存储过程
create or replace procedure
test(var_name_1 in type,var_name_2 out type) as
--声明变量(变量名 变量类型)
begin
--存储过程的执行体
end test;
打印出输入的时间信息
E.g:
create or replace procedure
test(workDate in Date) is
begin
dbms_output.putline('The
input date
is:'||to_date(workDate,'yyyy-mm-dd'));
end test;
2、变量赋值
变量名 := 值;
E.g:
create or replace procedure
test(workDate in Date) is
x number(4,2);
begin
x :=
1;
end test;
3、判断语句:
if 比较式 then begin end; end
if;
E.g
create or replace procedure 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;
4、For
循环
For ... in ... LOOP
--执行语句
end LOOP;
(1)循环遍历游标
create or replace procedure test()
as
Cursor cursor is select name from
student; name varchar(20);
begin
for name in cursor LOOP
begin
dbms_output.putline(name);
end;
end LOOP;
end test;
(2)循环遍历数组