• plsql一个函数的例子


    ------陈渝文统计报表优化一下午

    1
    create or replace type t_test as object 2 ( 3 HDID varchar2(60), 4 省份 varchar2(60), 5 派驻检察室数目 varchar2(60), 6 检所1 varchar2(60), 7 检所2 varchar2(60), 8 检所3 varchar2(60), 9 检所4 varchar2(60) 10 ) 11 / 12 create or replace type t_test_table as table of t_test; 13 / 14 CREATE OR REPLACE FUNCTION FN_GET_ADMINISTRATIVE_LEAF RETURN t_test_table AS 15 16 cursor shengji_c is 17 select T1.PINDEX, t1.B00, t1.B0101 18 from B01 t1 19 where t1.ZDYXB0132 = 'M03' 20 and (t1.flag is null or t1.flag = '0'); 21 22 TYPE refcur_type IS REF CURSOR; 23 book_refcur refcur_type; 24 25 V_PINDEX varchar2(100); 26 V_B00 varchar2(100); 27 V_B0101 varchar2(100); 28 29 V_ZDYXB0131 varchar2(100); 30 31 V_JS01 number := 0; 32 V_JS02 number := 0; 33 V_JS03 number := 0; 34 V_JS04 number := 0; 35 36 V_INDEX number := 1; 37 38 v_test t_test_table := t_test_table(); 39 begin 40 41 open shengji_c; 42 loop 43 fetch shengji_c 44 into V_PINDEX, V_B00, V_B0101; 45 exit when shengji_c%notfound; 46 47 V_JS01 := 0; 48 V_JS02 := 0; 49 V_JS03 := 0; 50 V_JS04 := 0; 51 52 open book_refcur for 53 SELECT ZDYXB0131 54 FROM B01 t 55 where (t.ZDYXB0131 like '%170%' or t.ZDYXB0131 like '%171%' or 56 t.ZDYXB0131 like '%172%' or t.ZDYXB0131 like '%173%') 57 start with b00 = V_B00 58 CONNECT BY PRIOR B00 = B0144B 59 and (t.flag is null or t.flag = '0'); 60 61 loop 62 fetch book_refcur 63 into V_ZDYXB0131; 64 exit when book_refcur%notfound; 65 if (V_ZDYXB0131 like '%170%') then 66 V_JS01 := V_JS01 + 1; 67 end if; 68 if (V_ZDYXB0131 like '%171%') then 69 V_JS02 := V_JS02 + 1; 70 end if; 71 if (V_ZDYXB0131 like '%172%') then 72 V_JS03 := V_JS03 + 1; 73 end if; 74 if (V_ZDYXB0131 like '%173%') then 75 V_JS04 := V_JS04 + 1; 76 end if; 77 end loop; 78 79 v_test.extend(); 80 v_test(V_INDEX) := t_test(V_B00, 81 V_B0101, 82 'aaa', 83 V_JS01, 84 V_JS02, 85 V_JS03, 86 V_JS04); 87 V_INDEX := V_INDEX + 1; 88 89 end loop; 90 close shengji_c; 91 92 RETURN v_test; 93 END;
    除了写代码还会干什么
  • 相关阅读:
    html_py
    PHP-FPM详解
    nginx 虚拟主机配置
    正确配置Nginx+PHP
    centos7安装Nginx
    如何让浏览器关闭后session失效
    微擎中消息响应回复 代码流程
    在vue组件库中不能使用v-for
    微信分享前面
    php接受axios数据
  • 原文地址:https://www.cnblogs.com/zyx-/p/8028608.html
Copyright © 2020-2023  润新知