Oracle Array type

Source: Internet
Author: User

Create or Replace functionMy_test (p_strvarchar2)return  Number as--Common VariablesV_varvarchar2( +);--fixed-length arraysType V_ar isVarray (Ten) of varchar2( -); My_ar V_ar:=V_ar ('g','m','D','Gong','Handsome');--variable Length valueType Type_array is Table  of varchar2( -)Index  byBinary_integer;  Var_array Type_array; --similar to two-dimensional arraysType Serv_array is Table  ofItmis_pri_serv_tbl%RowTypeIndex  byBinary_integer; Var_serv Serv_array;--a record block, a variable that holds a record, a struct similar to CTYPE T_myrecord isRecord (Field1 Number, Field2varchar2( -) ); Var_record T_myrecord; beginV_var:= 'Hello World';d Bms_output.put_line (v_var); forIinch 1.. My_ar.CountLoop Dbms_output.put_line (My_ar (i)); EndLoop; ------------------------------------------Var_array (1):='AA'; Var_array (2):='BB';--The subscript must be continuous  forIinch 1.. Var_array.CountLoop Dbms_output.put_line (Var_array (i)); EndLoop; --------------------------------------------can be used as a temporary table variable--SELECT * Bulk collect into Var_serv from ITMIS_PRI_SERV_TBL where year = 2013;--similar to two-dimensional arraysSelect * BulkCollect intoVar_serv fromitmis_pri_serv_tbl;--access to two-dimensional arrays   forIinch 1.. Var_serv.CountLoop Dbms_output.put_line (Var_serv (i). serv_id);  Dbms_output.put_line (Var_serv (i). status); EndLoop;--Record Quick access with Temp(Id,name) as(Select 1,'Sam'  fromDualUnion  AllSelect 2,'Tom'  fromDualUnion  AllSelect 3,'Kelly'  fromdual)SelectId,name intoVar_record from TempwhereId= 1;d Bms_output.put_line ('Var_record:'||Var_record. Field1||'  '||Var_record. FIELD2);returnlength (P_STR);End;/*1.COUNT Returns the number of elements in the collection 2.DELETE deletes all elements in the collection 3.DELETE (x) Delete element labeled X is illegal for varray            4.DELETE (x, y) Delete element subscript from X to Y element to Varray illegal 5.EXIST (x) returns True if the collection element x is already initialized, otherwise false 6.EXTEND Adds an element to the end of the collection to index_by illegal 7.EXTEND (x) adds x elements to the end of the collection to index_by illegal 8.EXTEND (x,n) at the end of the collection     An x copy of the element n index_by illegal 9.FIRST returns the lower label of the first element in the collection, and always returns 1 for the Varray collection.     10.LAST returns the lower label of the last element in the collection, which is always equal to count for the Varray return value.     11.LIMIT returns the maximum number of elements of the Varry collection index_by the collection and the nested table is useless 12.NEXT (x) returns the element value after the X element and immediately next to it, if X is the last element, returns NULL.     13.PRIOR (x) Returns the value of the element next to it before the X element, or null if x is the first element.   14.TRIM deletes an element starting at the end of the collection for index_by not valid 15.TRIM (x) removes the X element from the end of the set Var_array.next (3); Back to Var_array (3)*/

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.