Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Memory Table in PLSQL-- Index By Table

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In fact, a memory table is a bit like an array in java, but it is more powerful than an array.

1. First of all, let's briefly introduce the role of memory tables:

An index primary key made up of BINARY_INTEGER types

Fields of simple types or user-defined types as specific array elements

two。 How to use memory table types?

Define memory table types

TYPE type_name IS TABLE OF storage type (number, employees.last_name%TYPE, employees%ROWTYPE, varchar2)

INDEX BY (BINARY_INTEGER,varchar2 (80)..)

-varchar2 (80) indicates that subscripts can be accessed through strings, which is more powerful than arrays in java

Declare a variable of this type

Identifier type_name

3. Some properties and methods in memory table

Assignment:

Identifier (1): = 'Jams'-- this is index by binary_integer

Identifier ('A'): = 'Jams'-- this is index by varchar2

Unlike arrays in java, memory tables can use strings as subscript

3-1.count method:

Identifier.count-returns the number of rows in the memory table

3-2.exists method:

Identifier.exists (1)-determines whether an element with subscript 1 exists

3-3.first and last attributes:

First: the index that returns the first row

Last: returns the index of the last row

The usage of first and last:

Generally used in the case of traversing memory tables

For i in identifier.first.. Identifier.last loop .end loop

Two points must be noted here:

1. If there is no data in the memory table, but you traverse it in this way, you will report an error, so you should use the

Count method to make a judgment.

two。 What if the data subscript in the memory table is not contiguous?

For example, there are only identifier (2) and identifier (5) in memory tables.

When traversing to the subscript 1, 4, do exception or error handling, otherwise the error will be reported.

3-4.delete method:

Identifier.delete (1)-deletes the element with subscript 1 in the memory table

Identifier.delete-deletes all elements of the memory table

3-5.next and prior attributes:

Identifier.next (1)-returns the next row index in the memory table with subscript 1

Identifier.prior (2)-returns the index of the previous row in the memory table with a subscript of 2 rows

The function of INDEX BY BINARY_INTEGER is attached here.

-- http://blog.itpub.net/26690043/viewspace-722081/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report