当前位置:首页 » 存储配置 » 调用oracle存储过程返回值

调用oracle存储过程返回值

发布时间: 2023-12-09 01:22:10

1. oracle里面怎么调用有返回值的存储过程

create or replace procere xs_proc(temp_name in varchar2,
temp_num out number) is
num_1 number;
num_2 number;
begin
select yu_wen, shu_xue
into num_1, num_2
from xuesheng
where xing_ming = temp_name;
--dbms_output.put_line(num_1 + num_2);
temp_num := num_1 + num_2;
end;

单个返回值的oracle存储过程

2. Oracle获取存储过程输出参数返回值

CREATE OR REPLACE PROCEDURE sap_po_test(id IN NUMBER,
p_message OUT VARCHAR2) AS
mycount number(4) := 0;
BEGIN
SELECT COUNT(*)
INTO mycount
FROM 表
WHERE id = p_id;
IF mycount > 0 THEN
p_message := 'S';
ELSE
p_message := 'E';
END IF;
RETURN;
END;
( ⊙ o ⊙ )啊!

3. oracle怎么写一个无参存储过程去调用一个有参数有返回值的存储过程

create
procere
proc_a
as
declare
b
int;
c
varchar2(10);
begin
proc_b(b,
c);
dbms_output.put_line
(c);
end
procere
a;
你照我这个写吧
proc_b(b,
c);
proc_b是你调用的带返回参数的存储过程
b是输入变量,c是输出变量

4. oracle 怎么调用存储过程

ORACLE存储过程 以oracle自带例子数据库的表举例
1、

create or replace procere p
is
cursor c is
select * from emp2 for update;
begin
for v_emp in c loop
if(v_emp.sal <2000) then
update emp2 set sal =sal+1 where current of c ;
elsif(v_emp.sal>=2000) then
delete from emp2 where current of c;
end if;
end loop;
commit;
end;

创建了存储过程不代表运行了存储过程;
运行此存储过程 :
方式一 exec p;
方式二
begin
p;
end;
2、带参数的存储过程
in 相当于程序里的参数,供传入用,在存储过程不能改变其值;
out 相当于程序里的返回值,在存储过程中可以为其赋值传出;
in out 既可以当参数又可以当返回值用;
不带上述说明符默认为in类型;

下例中v_a v_b 为in类型
v_c 为out类型
v_d 为in out 类型

create or replace procere p(v_a in number,v_b number,v_c out number,v_d in out number)
is
begin
if(v_a > v_b) then
v_c := v_a;
else
v_c := v_b;
end if;
v_d := v_d+1;
end;

---> 调试时:
可以在命令窗口调试,出错时 用show errors 显示出错信息;
可以在plDv中调试;

---> 运行时:
可以在命令窗口运行:
declare
v_a number:=3;
v_b number:=4;
v_c number;
v_d number:=5;
begin
p(v_a,v_b,v_c,v_d);
dbms_output.put_line(v_c);
dbms_output.put_line(v_d);
end;
可以在plDv中调试;

5. shell如何获取oracle存储过程返回值

类似下面的方法:

fcp_login="<user>/<password>"
ret_value=`sqlplus-s$fcp_login<<EOF
setheadingoff
setfeedbackoff
setpages0
settrimspoolon
VARIABLEx_outnumVARCHAR2(30);
EXECUTEimportUserInfoDate1g(:x_outnum);
printx_outnum
exit;
EOF`

6. oracle 中运行存储过程作为返回值

oracle可以使用out型参数返回值,例如:

--查询某商品编号是否存在,返回查询状态
createorreplaceprocereproc_getGood
(
param_shopIdnumber,--商品编号
param_flagoutnumber--查询状态0不存在
)
as
declarev_countnumber(1);
begin
selectcount(*)intov_countfromtb_goodswhereshopid=param_shopid;

ifv_count=0then
param_flag:=0;
else
param_flag:=1;
endif;

end;

7. java调用oracle存储过程无法获得正确的返回值,每次都是0

你通过JDBC这种方式调用存储过程,应该使用 CallableStatement 类, CallableStatement cs=conn.prepareCall(str);

补充一句,避免你在执行有错,
cs.excuse();这个方法为执行,然后在获取输出参数。另外写输出参数的类型时,直Types.类型即可,不用带包。

热点内容
db2新建数据库 发布:2024-09-08 08:10:19 浏览:170
频率计源码 发布:2024-09-08 07:40:26 浏览:778
奥迪a6哪个配置带后排加热 发布:2024-09-08 07:06:32 浏览:100
linux修改apache端口 发布:2024-09-08 07:05:49 浏览:208
有多少个不同的密码子 发布:2024-09-08 07:00:46 浏览:566
linux搭建mysql服务器配置 发布:2024-09-08 06:50:02 浏览:995
加上www不能访问 发布:2024-09-08 06:39:52 浏览:811
银行支付密码器怎么用 发布:2024-09-08 06:39:52 浏览:513
苹果手机清理浏览器缓存怎么清理缓存 发布:2024-09-08 06:31:32 浏览:554
云服务器的优点与缺点 发布:2024-09-08 06:30:34 浏览:734