plsql learning - four:procedure

本文详细介绍了PL/SQL中过程的三种参数类型:IN、OUT、INOUT,并通过实例展示了不同参数类型的使用方法及效果。此外,还对比了传值与传引用的不同效率,指出在大量数据处理时使用nocopy选项可以显著提高程序运行速度。

There are three type of parameters of procedure,IN,OUT,IN OUT,here is the example:

create or replace procedure ModeTest(
 p_InParameter in number,
 p_OutParameter out number,
 p_InOutParameter in out number
) is
v_LocalVariable number:=0;
begin
  if(p_InParameter is null) then
    dbms_output.put_line('p_InParameter is NULL');
  else
    dbms_output.put_line('p_InParameter = '||p_InParameter);
  end if;

  if(p_OutParameter is null) then
    dbms_output.put_line('p_OutParameter is NULL');
  else
    dbms_output.put_line('p_OutParameter = '||p_OutParameter);
  end if;

  if(p_InOutParameter is null) then
    dbms_output.put_line('p_InOutParameter is NULL');
  else
    dbms_output.put_line('p_InOutParameter = '||p_InOutParameter);
  end if;


  p_OutParameter := 4;
  --p_InParameter := 9;illegal
  p_InOutParameter := 9;
  v_LocalVariable := p_InParameter;
  dbms_output.put_line(to_char(v_LocalVariable));
  v_LocalVariable := p_InOutParameter;
  dbms_output.put_line(to_char(v_LocalVariable));
  v_LocalVariable := p_OutParameter;
  dbms_output.put_line(to_char(v_LocalVariable));
  
  if(p_InParameter is null) then
    dbms_output.put_line('p_InParameter is NULL');
  else
    dbms_output.put_line('p_InParameter = '||p_InParameter);
  end if;

  if(p_OutParameter is null) then
    dbms_output.put_line('p_OutParameter is NULL');
  else
    dbms_output.put_line('p_OutParameter = '||p_OutParameter);
  end if;

  if(p_InOutParameter is null) then
    dbms_output.put_line('p_InOutParameter is NULL');
  else
    dbms_output.put_line('p_InOutParameter = '||p_InOutParameter);
  end if;
end ModeTest;

 then test it:input 1,2,3 for testing,result is 1,4,9

log printed is:

   Before assigned value:
   p_InParameter = 1
   p_OutParameter is NULL
   p_InOutParameter = 3
   After assigned value:
   p_InParameter = 1
   p_OutParameter = 4
   p_InOutParameter = 9;

then the example of nocopy usage:

create or replace package CopyFast as
  type StudentArray is table of students%rowtype;
  
  --procedure with using pass-by-value
  procedure PassStudents1(p_Parameter in StudentArray);
  --procedure with using pass-by-reference
  procedure PassStudents2(p_Parameter in out StudentArray);
  --procedure with using pass-by-value
  procedure PassStudents3(p_Parameter in out nocopy StudentArray);
  
  --test procedure
  procedure go;
end CopyFast;

create or replace package body CopyFast as
  procedure PassStudents1(p_Parameter in StudentArray) is
  begin
    null;
  end PassStudents1;
  
  procedure PassStudents2(p_Parameter in out StudentArray) is
  begin
    null;
  end PassStudents2;
  
  procedure PassStudents3(p_Parameter in out nocopy StudentArray) is
  begin
    null;
  end PassStudents3;
  
  procedure go is
    v_StudentArray StudentArray := StudentArray(NULL);
    v_StudentRec students%rowtype;
    v_Time1 number;
    v_Time2 number;
    v_Time3 number;
    v_Time4 number;
  begin
    --Fill up the array with 50001 copies of Daivid Dinsmore's record
    select * into v_StudentArray(1)
    from students where id = 10007;
    v_StudentArray.extend(50000,1);
    
    --call each version of procedure PassStudents,and time them.
    v_Time1 := dbms_utility.get_time;
    PassStudents1(v_StudentArray);
    v_Time2 := dbms_utility.get_time;
    PassStudents2(v_StudentArray);
    v_Time3 := dbms_utility.get_time;
    PassStudents3(v_StudentArray);
    v_Time4 := dbms_utility.get_time;
    
    --output the results
    dbms_output.put_line(to_char(v_Time3)||'=='||to_char(v_Time2));
    dbms_output.put_line('Time to pass IN :'||to_char((v_Time2-v_Time1)/100));
    dbms_output.put_line('Time to pass IN OUT:'||to_char((v_Time3-v_Time2)/100));
    dbms_output.put_line('Time to pass IN OUT NOCOPY:'||to_char((v_Time4-v_Time3)/100));
    end go;
 end CopyFast;

 then exec the procedure,result is:0,11,0

 so we can use nocopy for change pass-by-value to pass-by-reference of parameter.

代码转载自:https://pan.quark.cn/s/a4b39357ea24 本文重点阐述了利用 LabVIEW 软件构建的锁相放大器的设计方案及其具体实施流程,并探讨了该设备在声波相位差定位系统中的实际运用情况。 锁相放大器作为一项基础测量技术,其核心功能在于能够精确锁定微弱信号的频率参数并完成相关测量工作。 在采用 LabVIEW 软件开发的锁相放大器系统中,通过计算测量信号与两条参考信号之间的互相关函数,实现对微弱信号的频率锁定,同时输出被测信号的幅值信息。 虚拟仪器技术是一种基于计算机硬件平台的仪器系统,其显著特征在于用户可以根据实际需求自主设计仪器功能,配备虚拟化操作界面,并将测试功能完全由专用软件程序实现。 虚拟仪器系统的基本架构主要由计算机主机、专用软件程序以及硬件接口模块等核心部件构成。 虚拟仪器最突出的优势在于其功能完全取决于软件编程,用户可以根据具体应用场景灵活调整系统功能参数。 在基于 LabVIEW 软件开发的锁相放大器系统中,主要运用 LabVIEW 软件平台完成锁相放大器功能的整体设计。 LabVIEW 作为一个图形化编程环境,能够高效地完成虚拟仪器的开发工作。 借助 LabVIEW 软件,可以快速构建锁相放大器的用户操作界面,并且可以根据实际需求进行灵活调整和功能扩展。 锁相放大器系统的关键构成要素包括测量信号输入通道、参考信号输入通道、频率锁定处理单元以及信号幅值输出单元。 测量信号是系统需要检测的对象,参考信号则用于引导系统完成对测量信号的频率锁定。 频率锁定处理单元负责实现测量信号的锁定功能,信号幅值输出单元则负责输出被测信号的幅值大小。 在锁相放大器的实际实现过程中,系统采用了双路参考信号输入方案来锁定测量信号。 通过分析两路参考信号之间的相...
边缘计算环境中基于启发式算法的深度神经网络卸载策略(Matlab代码实现)内容概要:本文介绍了在边缘计算环境中,利用启发式算法实现深度神经网络任务卸载的策略,并提供了相应的Matlab代码实现。文章重点探讨了如何通过合理的任务划分与调度,将深度神经网络的计算任务高效地卸载到边缘服务器,从而降低终端设备的计算负担、减少延迟并提高整体系统效率。文中涵盖了问题建模、启发式算法设计(如贪心策略、遗传算法、粒子群优化等可能的候选方法)、性能评估指标(如能耗、延迟、资源利用率)以及仿真实验结果分析等内容,旨在为边缘智能计算中的模型推理优化提供可行的技术路径。; 适合人群:具备一定编程基础,熟悉Matlab工具,从事边缘计算、人工智能、物联网或智能系统优化方向的研究生、科研人员及工程技术人员。; 使用场景及目标:①研究深度神经网络在资源受限设备上的部署与优化;②探索边缘计算环境下的任务卸载机制与算法设计;③通过Matlab仿真验证不同启发式算法在实际场景中的性能表现,优化系统延迟与能耗。; 阅读建议:建议读者结合提供的Matlab代码进行实践操作,重点关注算法实现细节与仿真参数设置,同时可尝试复现并对比不同启发式算法的效果,以深入理解边缘计算中DNN卸载的核心挑战与解决方案。
内容概要:本文介绍了一套基于YOLOv5的实时打架行为识别与预警系统,旨在提升公共安全监控的智能化水平。系统通过四个核心模块实现完整功能:数据准备与标注、YOLOv5模型训练、实时视频流识别以及PyQt5开发的可视化界面。利用公开或自定义采集的打架行为数据集,经过标注和数据增强后,使用YOLOv5进行训练,获得高精度检测模型(准确率超92%)。模型部署于实时摄像头视频流中,结合OpenCV实现行为检测与即时预警,并通过PyQt5构建用户友好的图形界面,支持状态显示、报警提示等交互功能。系统具备低延迟(0.2秒内响应)、高准确性与可扩展性,适用于多种公共场景的安全监控。 适合人群:具备Python编程基础、熟悉深度学习框架(如PyTorch)的高校学生、科研人员及从事计算机视觉、安防系统开发的工程师,尤其适合需要完成毕业设计或实际安防项目的从业者。 使用场景及目标:①应用于商场、校园、地铁站等人流密集场所,实现对打架行为的自动识别与实时预警;②帮助开发者掌握从数据处理、模型训练到系统集成的全流程技术栈,理解YOLOv5在真实场景中的落地方法;③拓展至边缘设备部署、多行为识别等高级应用。 阅读建议:建议按照“数据→模型→识别→界面”的顺序逐步实践,配合提供的代码链接与密码下载完整资源,边学边调,重点关注模型训练参数设置与实时推理性能优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值