ORACLE array Definition

Source: Internet
Author: User
Tags array definition

ORACLE array definition Fixed Array www.2cto.com declare type type_array is varray (10) of varchar2 (20); -- one-dimensional array, string type var_array type_array: = type_array ('ggs ', 'jforward', 'wsb ', 'csl', 'dd', 'bb'); begin for I in 1 .. var_array.count loop -- use count dbms_output.put_line (var_array (I); end loop; end; 1. COUNT returns the number of elements in the Set www.2cto.com 2. DELETE: DELETE all elements in the set. 3. DELETE (x) Deleting an element whose subscript is x is invalid for VARRAY. 4. DELETE (x, y) The element whose subscript is from X to Y is invalid for VARRAY. EXIST (X) If array element x has been initialized, TRUE is returned; otherwise, FALSE 6 is returned. EXTEND adds an element at the end of the set that is invalid for Index_by. 7. EXTEND (x) adds x elements at the end of the Set, which is invalid for Index_by. EXTEND (x, n) adding x copies of element n at the end of the set is invalid for Index_by 9. FIRST returns the bottom label of the FIRST element in the Set, and 1 is always returned for the VARRAY set. 10. the bottom number of the LAST element in the LAST returned set. The return value for VARRAY is always equal to COUNT. 11. LIMIT returns the maximum number of elements in the VARRY set. The Index_by set and the nested table are useless. 12. NEXT (x) returns the element value after the x element and NEXT to it. If x is the last element, null is returned. 13. PRIOR (x) returns the value of the element next to it before the x element. If x is the first element, null is returned. 14. TRIM deletes an element from the end of the set. It is invalid for index_by. 15. TRIM (x) deletes x elements from the end of the Set var_array.next (3); // returns the var_array (3) variable array declare type type_array is table of varchar2 (20) index by binary_integer; var_array type_array; begin var_array (1): = 'a'; var_array (2): = 'bb'; -- the subscript must be continuous for I in 1 .. var_array.count loop dbms_output.put_line (var_array (I); end loop; end; declare type type_array is table of t_user % rowtype index by binary_integer; -- similar to a two-dimensional array var_array type_array; begin select * bulk collect into var_array from t_user; for I in 1 .. var_array.count loop dbms_output.put_line (var_array (I ). user_id); -- two-dimensional array access dbms_output.put_line (var_array (I ). username); end loop; end;

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.