Memory table--index by table in Plsql

Source: Internet
Author: User

In fact, the memory table is a bit like an array in Java, but it has a much stronger place than the array.

1. Let's start with a brief introduction to the memory table:

    • Index primary key using the Binary_integer type

    • Simple Type or a user-defined type of field as a specific array element

2. How do I use the memory table type?

Defining Memory Table Types

        TYPE type_nameis TABLE of Storage type (number,Employees.last_name%type, Employees%rowtype, VARCHAR2)    


INDEX by (BINARY_INTEGER,VARCHAR2 (80).)

---varchar2 (80) indicates that the subscript can be accessed through a string, which is more powerful than the array in Java

Declare the type variable

Identifier Type_name


3. Some properties and methods in the memory table

Assignment value:

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

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

The difference between an array in Java and a memory table can use a string as a subscript

Count Method:

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

Exists method:

Identifier.exists (1)--determining that an element with subscript 1 does not exist

First and Last properties:

First: returns the index of row one

Last: Returns the index of the final row

First and last usage:

Generally used in the case of traversing memory tables

For I in Identifier.first. Identifier.last loop ... end loop, ....

Here are two points to note:

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

Count method to make a judgment

2. What if the data in the memory table is not continuously labeled?

For example, the memory table is only identifier (2), identifier (5),

When traversing to subscript for 1,3,4, to do an exception or error handling, or will error.


This is accompanied by the role of index by Binary_integer

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



This article is from the "11768293" blog, please be sure to keep this source http://11778293.blog.51cto.com/11768293/1792626

Memory table--index by table 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.