一般存储过程的格式
create or replace procedure 存储过程名(param1 in type,param2 out type)
as
变量1 类型(值范围);
变量2 类型(值范围);
Begin
语句块
Exception --异常处理
When others then
Rollback;
End;
在SQL输入界面输入需需要创建的存储过程,
create or replace procedure sp_demo(param1 in varchar2,param2 out varchar2)
/*
* 存储过程实例
*/
as
cnt int;
rst varchar2(100)
Begin
Select count(*) into cst from Tab_Demo where Col_Value = param1;
If (cst > 0) then --判断条件
param2 := '有匹配的值';
Else
param2 := '无匹配的值';
End if;
Exception
When others then
Rollback;
End;
测试刚才编写的存储过程
exec sp_demo('男');