失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > Oracle中的存储过程在pl/sql和java中如何调用

Oracle中的存储过程在pl/sql和java中如何调用

时间:2020-07-27 20:55:55

相关推荐

Oracle中的存储过程在pl/sql和java中如何调用

数据库|mysql教程

oracle,Oracle中的存储过程在pl/sql和jav

数据库-mysql教程

易语言语音源码,vscode实时保存,如何查看Ubuntu上显卡驱动,Tomcat打印线程,使用Sqlite搭建app,jquery tag插件,流行的前端js框架,空气凤梨有黑色爬虫,php 网站 开源,AV在线SEO,国外服务器网站源码,企业招聘网页模板,安徽网 模板,网程序lzw

案例:添加学生,然后返回该班级的所有学生。create or replace procedure add_stu(p_sid stu.sid%type, p_sname stu.sn

搜索引擎源码 开源版,vscode受欢迎,祖鲁语 ubuntu,tomcat 环境量,sqlite 低并发,阿里云服务器 代理商,wordpress主题预览插件,前端框架结论与展望,爬虫箱内温度,培训php哪个机构好,如何对一个网站进行seo,php三合一网站模板下载,如何隐藏一个网页代码是什么原因,html多条件搜索模板,用户登陆注册页面代码,asp旅游信息管理系统,小程序源码查看器lzw

网址导航源码,ubuntu下玩饥荒,tomcat要和什么一起吃,java爬虫的目的,php网盘开源web版手机,seo经典地图lzw

案例:添加学生,然后返回该班级的所有学生。

create or replace procedure add_stu(

p_sid stu.sid%type,

p_sname stu.sname%type,

p_cid stu.cid%type,

p_data out sys_refcursor— 输出变量,系统引用游标

)

as

begin

insert into stu(sid,sname,cid)

values(p_sid,p_sname,p_cid);

commit;

–将查询的结果集的地址放到引用游标变量中,,再传递出去

open p_data for select * from stu where cid=p_cid;

end;

–PL/SQL 调用

declare

stu_data sys_refcursor;

stu_row stu%rowtype;

begin

add_stu(52,’b’,1,stu_data);

fetch stu_data into stu_row;

while(stu_data%found)

loop

dbms_output.put_line(stu_row.sname);

fetch stu_data into stu_row;

end loop;

close stu_data;

end;

–java中调用

CallableStatement cstmt = null;

String spName = “{call add_stu(?,?,?,?)}”;

cstmt = conn.prepareCall(spName);

cstmt.setInt(1, 工号);

…………

cstmt.registerOutParameter(4, Oracle.jdbc.OracleTypes.CURSOR); –设置第4个问号的值

cstmt.executeUpdate();

ResultSet rs = (ResultSet)cstmt.getObject(4);

如果觉得《Oracle中的存储过程在pl/sql和java中如何调用》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。