简单的存储过程案例

xiaoxiao2021-02-28  77

这是一个创建存储过程的模板代码 直接复制粘贴 修改表名就可用 --创建存储过程 create or replace produce getCount(typeno in varchar2,keycode in varchar2) --声明变量 is var_name varchar2(32); var_dicname varchar2(128); --声明一个游标 cursor key_content is --给游标赋值 编写具有结果集的sql语句 select key_word_content from iqm_quality_keyword where key_word_type = keycode; --定义一个游标变量 获取每一个游标的对象 first_content key_content%rowtype; begin     --给变量赋值     var_name := 'helloworld';     --将sql语句查询的结果返回给指定的变量     select dic_name into var_dicname from iqm_base_code where dic_code = typeno and dic_type = 'busiType';     --将变量输出显示     dbms_output.put_line('直接赋值的变量为:'+var_name);     dbms_output.put_line('通过sql赋值的变量为:'+var_dicname);     --遍历游标获取结果     for first_content in key_content loop         --在这里获取游标的结果需要.字段名  不能直接输出变量 dbms_output.put_line('通过游标赋值的变量为:'+first_content.key_word_content);     end loop; end;
转载请注明原文地址: https://www.6miu.com/read-62599.html

最新回复(0)