How to determine whether the three sets in PLSQL are empty

Source: Internet
Author: User

 

Use count to determine the associative array, because the index-by TABLE statement is initialized, and the count statement will not cause an exception.

Cardinality is used to determine the nested table, because if the declared nested table is not initialized, using count will cause an exception, the minimum subscript of the nested table is not necessarily 1 (after the delete operation), so it cannot be determined by exists (1. You can only use cardinality.

Use exists (1) to judge varray, because if it is not initialized during varray declaration, using count will cause an exception, without the cardinality function, and the minimum subscript of varray is 1, therefore, you can use exists (1) to determine.

ExampleCode:
Declare
Type test_varray is varray (2) of varchar2 (10 );
Test_id_tab1 test_varray;

Type test_tab is table of varchar2 (10 );
Test_id_tab2 test_tab;

Type test_itab is table of varchar2 (10) index by binary_integer;
Test_id_tab3 test_itab;

CNT integer;
EXT Boolean;

Begin

Ext: = test_id_tab1.exists (1 );
If ext then
Dbms_output.put_line ('exist ');
Else
Dbms_output.put_line ('not exist ');
End if;

CNT: = cardinality (test_id_tab2 );
Dbms_output.put_line ('Count' | CNT );

CNT: = test_id_tab3.count;
Dbms_output.put_line ('Count' | CNT );

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.