Using two-dimensional storage structure---two-dimensional array in Plsql

Source: Internet
Author: User

The code is as follows:

The concept of no arrays in--plsql replaces multidimensional arrays with type and table of record
--create by Jenrry 20171028
--1.0 set up a test table for storing columns
CREATE TABLE cux.cux_test_jenrry_1028
(
Line_1 VARCHAR2 (240),
Line_2 VARCHAR2 (240),
Line_3 VARCHAR2 (240),
Line_4 VARCHAR2 (240),
Line_5 VARCHAR2 (240),
Line_6 VARCHAR2 (240),
Line_7 VARCHAR2 (240),
Line_8 VARCHAR2 (240),
Line_9 VARCHAR2 (240),
Line_10 VARCHAR2 (240),
Line_11 VARCHAR2 (240),
Line_12 VARCHAR2 (240),
Line_13 VARCHAR2 (240),
Line_14 VARCHAR2 (240),
Line_15 VARCHAR2 (240)
)
Tablespace Apps_ts_tx_data
Pctfree 10
Initrans 1
Maxtrans 255
Storage
(
Initial 128
Next 128
Minextents 1
Maxextents Unlimited
Pctincrease 0
);
Create synonym apps.cux_test_jenrry_1028 for cux.cux_test_jenrry_1028;

--2.0 An example of using a two-dimensional array
DECLARE
TYPE Test_type is RECORD (
Line_1 Cux_test_jenrry_1028.line_1%type,
Line_2 Cux_test_jenrry_1028.line_2%type,
Line_3 Cux_test_jenrry_1028.line_3%type,
Line_4 Cux_test_jenrry_1028.line_4%type,
Line_5 Cux_test_jenrry_1028.line_5%type,
Line_6 Cux_test_jenrry_1028.line_6%type,
Line_7 Cux_test_jenrry_1028.line_7%type,
Line_8 Cux_test_jenrry_1028.line_8%type,
Line_9 Cux_test_jenrry_1028.line_9%type,
Line_10 Cux_test_jenrry_1028.line_10%type,
Line_11 Cux_test_jenrry_1028.line_11%type,
Line_12 Cux_test_jenrry_1028.line_12%type,
Line_13 Cux_test_jenrry_1028.line_13%type,
Line_14 Cux_test_jenrry_1028.line_14%type,
Line_15 Cux_test_jenrry_1028.line_15%type); --Define Test record type
TYPE Test_type_array is TABLE of Test_type INDEX by Binary_integer; --Defines the type of array that holds the Test record
Test_rec Test_type; --Declaring variables, type: Test record type
Test_rec_array Test_type_array; --Declaring variables, type: The array type that holds the Test record

BEGIN
--Array Assignment
Test_rec.line_1: = ' amount/column name ';
test_rec.line_2: = ' 30 ';
Test_rec_array (1): = Test_rec;

Test_rec.line_1: = ' 23 ';
Test_rec.line_3: = ' 11 ';
Test_rec_array (2): = Test_rec;

--loop output array elements
For I in 1.. Test_rec_array.count LOOP
Dbms_output. Put_Line (' i= ' | | | | | ', line_1= ' | | Test_rec_array (i)
. line_1 | | ', line_2= ' | | Test_rec_array (i). line_2);
END LOOP;
END;

Using two-dimensional storage structure---two-dimensional array in Plsql

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.