Oracle array, oracle

Source: Internet
Author: User

Oracle array, oracle

Defines an array of 5 strings.

Type str_array is varray (5) of varchar2 (30 );

V_str_array str_array: = expr_key_array ('A', 'bb ', 'cc', 'dd', 'ee ');

For I in 1 .. v_str_array. count loop
Dbms_output.put_line (v_expr_key );

End loop;


Define a variable-length String Array

Type str_array is table of varchar2 (20) index by binary_integer; v_str_array str_array;
V_str_array (1): = 'a ';
V_str_array (2): = 'bb ';
V_str_array (3): = 'cc ';


Oracle array Length

Declare
Type array_type is array (5) of number (2 );
A array_type: = array_type (5, 5, 5, 5 );
Begin
For I in 1 .. a. count loop
DBMS_OUTPUT.PUT_LINE (a (I ));
End loop;
End;
/
Remember, the maximum length of your array is 5, And I initialized 5 data for you. If I give you three initial data records, the actual length of your array is 3. If you use a (4), the array is out of bounds. Below is a method for extending the array:
Declare type array_type is array (5) of number (2 );
A array_type: = array_type ();
Begin
For I in 1 .. 5 loop
A. extend;
A (I): = I;
End loop;

For I in 1 .. a. count loop DBMS_OUTPUT.PUT_LINE (a (I ));
End loop;
End;
/

Of course, you can also use a. extend (5) To directly expand 5 (this extension length cannot be greater than 5)

You have an error understanding that type a is array (5) of number (2). This statement only declares a data type (array type)
At this time, your a and number (2) mean
A array_type: = array_type (5, 5, 5, 5); this defines an array variable.

ORACLE array Problems

Give you a thought, write the array in the Program (that is, the VB you use. NET), spell SQL statements in the program, and then use ADO. NET.
Below is the pseudocode
String [] Conditions = new stringp [] {"aa", "bb", "cc"}; // store the where condition to the array
For (int I = 0; I <Conditions. Length; I ++) // traverses your conditional Array
{
String SQL = "select * from table name where condition =" + Conditions [I]; // spell SQL statement
Export eldatareader reader = cmd. ExecuteQuery (SQL); // use ADO. NET to obtain the data set you need
}
 

Related Article

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.