首页 > 数据库 >oracle存储过程返回结果集SYS_REFCURSOR

oracle存储过程返回结果集SYS_REFCURSOR

时间:2023-01-19 14:01:11浏览次数:40  
标签:-- number param SYS REFCURSOR rent oracle null row

create or replace procedure proc_query_rent
(
param_region varchar2,--定义区
param_room number,--定义室
param_hall number,--定义厅
param_rentMin number,--定义租金上限
param_rentMax number,--定义租金下限
param_resultSet OUT SYS_REFCURSOR --定义out参数返回结果集
)
as
--v_text_sql varchar2(500);
begin
open param_resultSet for
select * from tb_rent
where
region like
case
when param_region IS null then '%'
else param_region
end
AND
room like
case
when param_room IS null then '%'
else to_char(param_room)
end
AND
hall like
case
when param_hall IS null then '%'
else to_char(param_hall)
end
AND
rent between
case
when param_rentMin IS null then 0
else param_rentMin
end
AND
case
when param_rentMax IS null then 99999999
else param_rentMax
end;
end;

declare
v_rent_rows SYS_REFCURSOR;
v_rent_row tb_rent%rowType;
begin
proc_query_rent('山区',null,null,1200,null,v_rent_rows);
Dbms_output.put_line('所在区 室 厅 租金');
loop
fetch v_rent_rows into v_rent_row;
exit when v_rent_rows%NOTFOUND;
Dbms_output.put_line(v_rent_row.region||' '||v_rent_row.room||' '||v_rent_row.hall||' '||v_rent_row.rent);
end loop;
close v_rent_rows;
end;

标签:--,number,param,SYS,REFCURSOR,rent,oracle,null,row
From: https://www.cnblogs.com/ivenlin/p/17061389.html

相关文章

  • Oracle 日期分页
    select*fromli.bookswherebook_publish_datebetween'1-2月-2005'and'1-2月-2010'; select*frombookswherebook_pricebetween50and60; select*frombo......
  • Oasys-RTL工具的使用(一)
    Oasys-RTL工具的作用,用官方的语言来说就是:enableyoutostartwithRTLandproduceaplacement-awareoptimizednetlistandfloorplan.也就是Oasys-RTL可以基于RTL做......
  • Oracle(一)
    文章目录​​1、Oracle简介​​​​1.1、Oracle公司发展历史​​​​1.2、Oracle几个重要的版本​​​​2、Oracle安装和配置​​​​2.1、安装Oracle数据库​​​​2.2、卸......
  • 第四十九章 使用 ^SystemPerformance 监视性能 - 复制配置文件
    第四十九章使用^SystemPerformance监视性能-复制配置文件复制配置文件可以使用以下API命令将现有配置文件复制到具有不同名称的文件:setrc=$$copyprofile^System......
  • 第四十八章 使用 ^SystemPerformance 监视性能 - 生成配置文件
    第四十八章使用^SystemPerformance监视性能-生成配置文件生成配置文件可以使用以下API命令快速生成新的配置文件(具有有意义的名称和描述):setrc=$$genprofile^Sys......
  • SQL优化案例10(ORACLE SQL语句逻辑读高优化案例)
    川川找我优化SQL,逻辑读达到398,000,安排一下。SQL和执行计划:SELECTt1.*,t3.bed_number,t3.patient_name,t4.nameFROModw_checkrecipe_resultt1leftjoinle......
  • Docker下部署oracle10g
    1.拉取oracle10g镜像文件dockerpullvkanjilal/oracle10g2.创建挂载目录mkdir-p/data/oracle1og3.创建oracle容器dockerrun-d-p1521:1521-v/data/oracle10g:/......
  • Oracle创建定时任务调用存储过程
    1.创建一个测试表testcreatetabletest(timedate);2.创建一个存储过程createorreplaceproceduretestasbegininsertintotestvalues(sysdate);end;3.定时任......
  • [SUCTF 2019]EasySQL
    原文链接:https://blog.csdn.net/m0_55771794/article/details/118709290这道题目需要我们去对后端语句进行猜解1、输入非零数字得到的回显1和输入其余字符得不到回显=>来......
  • systemd服务管理后台进程程序(编写systemd开机自启程序)
    【干货】Linux使用Systemd管理进程服务点击关注......