• <tfoot id='RJBeM'></tfoot>
    1. <i id='RJBeM'><tr id='RJBeM'><dt id='RJBeM'><q id='RJBeM'><span id='RJBeM'><b id='RJBeM'><form id='RJBeM'><ins id='RJBeM'></ins><ul id='RJBeM'></ul><sub id='RJBeM'></sub></form><legend id='RJBeM'></legend><bdo id='RJBeM'><pre id='RJBeM'><center id='RJBeM'></center></pre></bdo></b><th id='RJBeM'></th></span></q></dt></tr></i><div id='RJBeM'><tfoot id='RJBeM'></tfoot><dl id='RJBeM'><fieldset id='RJBeM'></fieldset></dl></div>
        <bdo id='RJBeM'></bdo><ul id='RJBeM'></ul>

        <small id='RJBeM'></small><noframes id='RJBeM'>

        <legend id='RJBeM'><style id='RJBeM'><dir id='RJBeM'><q id='RJBeM'></q></dir></style></legend>

        在 PL/SQL 中创建或模拟二维数组

        时间:2023-08-19
      1. <i id='Jv5yN'><tr id='Jv5yN'><dt id='Jv5yN'><q id='Jv5yN'><span id='Jv5yN'><b id='Jv5yN'><form id='Jv5yN'><ins id='Jv5yN'></ins><ul id='Jv5yN'></ul><sub id='Jv5yN'></sub></form><legend id='Jv5yN'></legend><bdo id='Jv5yN'><pre id='Jv5yN'><center id='Jv5yN'></center></pre></bdo></b><th id='Jv5yN'></th></span></q></dt></tr></i><div id='Jv5yN'><tfoot id='Jv5yN'></tfoot><dl id='Jv5yN'><fieldset id='Jv5yN'></fieldset></dl></div>
      2. <legend id='Jv5yN'><style id='Jv5yN'><dir id='Jv5yN'><q id='Jv5yN'></q></dir></style></legend>

              <tbody id='Jv5yN'></tbody>

            <small id='Jv5yN'></small><noframes id='Jv5yN'>

              <tfoot id='Jv5yN'></tfoot>
                  <bdo id='Jv5yN'></bdo><ul id='Jv5yN'></ul>
                • 本文介绍了在 PL/SQL 中创建或模拟二维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  你能帮助我如何在 PL/SQL 中为存储过程创建二维数组吗?列是动态的,因此它也可以增长和改变类型.任何帮助表示赞赏.提前谢谢你!

                  Can you please help me how can I create two dimensional array in PL/SQL for Stored Procedure? The columns are dynamic so it can grow and change in types also. Any help is appreciated. Thank you in advance!

                  我有以下代码:

                  Type CAR_TABLE_ARRAY is varray(2) of varchar2(255);
                  TYPE CAR_TABLE_TYPE IS TABLE OF CAR_TABLE_ARRAY;
                  CAR_TABLE CAR_TABLE_TYPE;
                  
                  CAR_TABLE := CAR_TABLE_TYPE();
                  CAR_TABLE.EXTEND(10);
                  CAR_TABLE(1)(1) := 'DODGE';
                  CAR_TABLE(2)(1) := 'FORD';
                  CAR_TABLE(3)(1) := 'MUSTANG';
                  CAR_TABLE(4)(1) := 'EDSEL';
                  CAR_TABLE(5)(1) := 'STUDEBAKER';
                  
                  DBMS_OUTPUT.put_line( '1 ' || CAR_TABLE(1)(1) );
                  DBMS_OUTPUT.put_line( '2 ' || CAR_TABLE(2)(1) );
                  DBMS_OUTPUT.put_line( '3 ' || CAR_TABLE(3)(1) );
                  DBMS_OUTPUT.put_line( '4 ' || CAR_TABLE(4)(1) );
                  DBMS_OUTPUT.put_line( '5 ' || CAR_TABLE(5)(1) );
                  

                  运行时出现以下错误:

                  ORA-06531:对未初始化集合的引用

                  ORA-06531: Reference to uninitialized collection

                  推荐答案

                  以下是在 pl/sql 中使用多维数组的示例.这里我使用了一个包含数组的数组.

                  Here's an example of using an multidimensional array in pl/sql. Here I use an array containing an array.

                  declare
                  
                    type t_features is table of varchar(100) index by pls_integer;
                    type t_car_rec is record
                    (
                      make varchar2(50),
                      model varchar2(50),
                      features t_features
                    );
                  
                    type t_car_tab is table of t_car_rec index by pls_integer;
                    car_tab t_car_tab;
                  
                    procedure show_detail is
                      car_idx pls_integer;
                      features_idx pls_integer;
                    begin
                      car_idx := car_tab.first;
                      loop
                        exit when car_idx is null;
                        dbms_output.put_line('Details for ' || car_tab(car_idx).make || ' ' || car_tab(car_idx).model);
                  
                        features_idx := car_tab(car_idx).features.first;
                        loop
                          exit when features_idx is null;
                          dbms_output.put_line('   =>' || car_tab(car_idx).features(features_idx));
                  
                          features_idx := car_tab(car_idx).features.next(features_idx);
                        end loop;
                  
                        car_idx := car_tab.next(car_idx);
                      end loop;
                    end;
                  
                  begin
                  
                    -- using sequential index values
                    car_tab(1).make := 'Ferrari';
                    car_tab(1).model := 'Testarossa';
                    car_tab(1).features(1) := 'Fast';
                    car_tab(1).features(2) := 'Looks cool';
                    car_tab(1).features(3) := 'Expensive';
                  
                    -- using random index values (sparse)
                    car_tab(2).make := 'Acura';
                    car_tab(2).model := 'TSX';
                    car_tab(2).features(14) := 'Small';
                    car_tab(2).features(200) := 'Good MPG';
                    car_tab(2).features(36) := 'Inexpensive';
                  
                    show_detail;
                  
                  end;
                  

                  输出将是:

                  Details for Ferrari Testarossa
                    =>Fast
                    =>Looks cool
                    =>Expensive 
                  Details for Acura TSX
                    =>Small
                    =>Inexpensive
                    =>Good MPG
                  

                  希望有帮助

                  这篇关于在 PL/SQL 中创建或模拟二维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何仅使用javascript将图像转换为字节数组以将图 下一篇:用于 JSON 输出整数数组的 SQL Server 2016

                  相关文章

                  最新文章

                • <legend id='2Egpu'><style id='2Egpu'><dir id='2Egpu'><q id='2Egpu'></q></dir></style></legend>
                • <small id='2Egpu'></small><noframes id='2Egpu'>

                  • <bdo id='2Egpu'></bdo><ul id='2Egpu'></ul>

                      <tfoot id='2Egpu'></tfoot>

                      <i id='2Egpu'><tr id='2Egpu'><dt id='2Egpu'><q id='2Egpu'><span id='2Egpu'><b id='2Egpu'><form id='2Egpu'><ins id='2Egpu'></ins><ul id='2Egpu'></ul><sub id='2Egpu'></sub></form><legend id='2Egpu'></legend><bdo id='2Egpu'><pre id='2Egpu'><center id='2Egpu'></center></pre></bdo></b><th id='2Egpu'></th></span></q></dt></tr></i><div id='2Egpu'><tfoot id='2Egpu'></tfoot><dl id='2Egpu'><fieldset id='2Egpu'></fieldset></dl></div>