oracle collection

  • 2020-06-23 02:09:10
  • OfStack

EXISTS

This function returns

The index of the first element in the collection, returns NULLNULLNULL if the collection is empty

Collection.EXISTS(index)

COUNT

The set of functions

Number of elements

Collection.COUNT

DELETE

This procedure deletes one or more or a combination of elements from a nested table

Table_name.DELETE deletes all elements

Table_name.delete (index) deletes the record for the specified index

Table_name.delete (start_index,end_index) deletes elements in the interval

FIRST

Returns the index of the first element of the collection, or NULL if the collection is empty

Collection.FIRST

LAST

Returns the last element index in the collection or NULL if the collection is empty

Collection. LAST

NEXT

Returns the index of the next element of the current element of the collection, NULL if it does not exist

Collection. NEXT

PRIOR

Returns the index of the previous element of the current element of the collection, or NULL if it does not exist

Collection. PRIOR

LIMIT

Returns the maximum number of elements created in varray

Collection. LIMIT

EXTENDS

This procedure adds a new element at the end of the collection

Collection.EXTEND adds 1 NULL element; Collection.extends(n) adds N NULL elements and ES110en.extend (n,index) adds n subtables of elements at the location specified by index

TRIM

Deletes an element from the end of the collection

Collection. TRIM removes the last element

Collection.TRIM(n) removes the last N elements

The set in which data is added
Unlike ES134en-ES135en tables, varray and nested tables can be stored in a database as jen in an object-relational table. They can also be used as columns in an object-relational table. To represent the data type as a database column, the collection type must be visible in pl/sql and sql. This needs to be defined using the create or replace type statement and cannot be defined locally only in the pl/sql block. The syntax is as follows:
create of replace type table_name is table of data_type

------from to me

I. Sheet type

-- Indexes organize tables, tables that are stored in memory.
DECLARE
TYPE t_indexTable IS TABLE OF emp%ROWTYPE NOT NULL INDEX BY BINARY_INTEGER;
v_indexTable t_indexTable;
CURSOR v_cur IS
SELECT * FROM emp;
BEGIN
FOR c IN v_cur LOOP
v_indexTable(c.empno):=c;
IF v_indexTable.EXISTS(c.empno) THEN
DBMS_OUTPUT.PUT_LINE('v_indexTable('||c.empno||').empno=' || c.empno
||';v_indexTable('||c.empno||').ename='||c.ename);
ELSE
DBMS_OUTPUT.PUT_LINE('v_indexTable('||c.empno||'): non-existent ');
END IF;
END LOOP;
END;

Note :INDEX BY BINARY_INTEGER represents an index table, otherwise it is a nested table. The subscript of a table type must be continuous, so a subscript value can be deleted, not an array type.


Related articles: