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
}