zoukankan      html  css  js  c++  java
  • oracle中数组的运用

    --- define 一维数组

    DECLARE
    TYPE T_VARRAY IS VARRAY(5) OF NUMBER;
    V_VAR T_VARRAY := T_VARRAY(1, 2, 3, 4, 5);
    BEGIN
    FOR I IN 1 .. V_VAR.COUNT LOOP
    DBMS_OUTPUT.PUT_LINE(V_VAR(I));
    END LOOP;
    END;

    ---define 二维数组

    declare
    type structlist is table of varchar2(20);
    type struct_structlist is table of structlist;
    sl struct_structlist;
    begin
    sl := struct_structlist(structlist('10a', 20, 30, 40, 50),
    structlist(10, '20a', 30, 40, 50),
    structlist(1, 2, '3a', 4, 5));
    for i in sl.first .. sl.last loop
    for j in sl(i).first .. sl(i).last loop

    dbms_output.put_line(sl.count||' @ '||sl(i).count||' - '||sl(i) (j));
    end loop;
    end loop;
    end;

    DECLARE
    TYPE T_VARRAY IS VARRAY(5) OF varchar2(10);
    TYPE T_VARRAY_VARRAY IS VARRAY(4) OF T_VARRAY;
    V_VAR T_VARRAY_VARRAY := T_VARRAY_VARRAY(T_VARRAY('10a', 20, 30, 40, 50),
    T_VARRAY(10, '20a', 30, 40, 50),
    T_VARRAY(1, 2, '3a', 4, 5),
    T_VARRAY(1, 2, 3, 4, 5));
    begin
    FOR I IN 1 .. V_VAR.COUNT LOOP
    FOR J IN 1 .. V_VAR(I).COUNT LOOP
    DBMS_OUTPUT.PUT_LINE(V_VAR(I) (J));
    END LOOP;
    END LOOP;
    END;

  • 相关阅读:
    bzoj 2878: [Noi2012]迷失游乐园
    端口安全检查shell脚本
    Linux安全基线检查脚本
    kali修改时区
    Elasticsearch+Kibana+Logstash安装
    go基础语法
    windows server 2012泛域名解析配置
    域名解析知识总结
    DDOS防护原理
    kali 2.0下搭建DVWA环境
  • 原文地址:https://www.cnblogs.com/quanweiru/p/2616150.html
Copyright © 2011-2022 走看看