1.创建测试存储过程SQL
[oracle@node01:/home/oracle]$ cat proc_test.sql
/*****
** 创建加、减、乘、除计算的存储过程
**输入参数: 数字1,数字2,计算类型
**输出参数: 数字3
*****/
create or replace procedure Proc_Test
(
--定义输入、输出参数--
num_A in integer,
num_B in integer,
numType in integer,
num_C out integer
)
as
--定义变量--
-- numCount integer;
-- numStr varchar(20);
begin
--判断计算类型--
if numType=1 then
num_C := num_A + num_B;
elsif numType=2 then
num_C := num_A - num_B;
elsif numType=3 then
num_C := num_A * num_B;
elsif numType=4 then
num_C := num_A / num_B;
else
--其它处理
dbms_output.put_line('其它处理');
end if;
end;
2.创建存储过程
sys@testDB 14:19:36> @ /home/oracle/proc_test.sql
28 /
Procedure created.
3.调用存储过程
declare num_C integer;
begin
--调用存储过程---
Proc_Test(3,4,3,num_C);
dbms_output.put_line('输出结果:'|| num_C );
end;
4.执行效果
输出结果:12
版权声明:本文为博主原创文章,未经博主允许不得转载。
oracle
- 上一篇:Python strip()方法
- 下一篇:Oracle bigfile表空间