案例:添加学生,然后返回该班级的所有学生。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中如何插入特殊字符:& 和 "(多种解决方案)Oracle 查询指定表名的columns相关资讯 oracle
- [INS-32052] Oracle基目录和Oracle (07/22/2014 07:41:41)
- Oracle 4个大对象(lobs)数据类型 (02/03/2013 12:33:05)
- Oracle按时间段分组统计 (07/26/2012 10:36:48)
| - [Oracle] dbms_metadata.get_ddl的 (07/12/2013 07:37:30)
- Liferay Portal 配置使用Oracle和 (07/31/2012 20:07:18)
- Concurrent Request:Inactive (07/20/2012 07:44:05)
|
本文评论 查看全部评论 (0)