简单的存储过程案例

来源:互联网 发布:普宁淘宝培训学校在哪 编辑:程序博客网 时间:2024/06/07 07:59
这是一个创建存储过程的模板代码  直接复制粘贴 修改表名就可用
--创建存储过程create or replace produce getCount(typeno in varchar2,keycode in varchar2)--声明变量isvar_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;

原创粉丝点击