SQL>
SQL> CREATE TABLE MyTable (
2 num_col NUMBER,
3 char_col VARCHAR2(60)
4 );
Table created.
SQL>
SQL> DECLARE
2 TYPE t_Numbers IS TABLE OF MyTable.num_col%TYPE
3 INDEX BY BINARY_INTEGER;
4 TYPE t_Chars IS TABLE OF MyTable.char_col%TYPE
5 INDEX BY BINARY_INTEGER;
6 v_Numbers t_Numbers;
7 v_Chars t_Chars;
8 BEGIN
9 -- Fill up the arrays with 50 rows.
10 FOR v_Count IN 1..50 LOOP
11 v_Numbers(v_Count) := v_Count;
12 v_Chars(v_Count) := 'Row number ' || v_Count;
13 END LOOP;
14
15 -- And insert them into the database using bulk binds.
16 FORALL v_Count IN 1..50
17 INSERT INTO MyTable VALUES
18 (v_Numbers(v_Count), v_Chars(v_Count));
19 END;
20 /
PL/SQL procedure successfully completed.
SQL>
SQL> select * from MyTable;
NUM_COL CHAR_COL
-------- ------------------------------------------------------------
1.00 Row number 1
2.00 Row number 2
3.00 Row number 3
4.00 Row number 4
5.00 Row number 5
6.00 Row number 6
7.00 Row number 7
8.00 Row number 8
9.00 Row number 9
10.00 Row number 10
11.00 Row number 11
NUM_COL CHAR_COL
-------- ------------------------------------------------------------
12.00 Row number 12
13.00 Row number 13
14.00 Row number 14
15.00 Row number 15
16.00 Row number 16
17.00 Row number 17
18.00 Row number 18
19.00 Row number 19
20.00 Row number 20
21.00 Row number 21
22.00 Row number 22
NUM_COL CHAR_COL
-------- ------------------------------------------------------------
23.00 Row number 23
24.00 Row number 24
25.00 Row number 25
26.00 Row number 26
27.00 Row number 27
28.00 Row number 28
29.00 Row number 29
30.00 Row number 30
31.00 Row number 31
32.00 Row number 32
33.00 Row number 33
NUM_COL CHAR_COL
-------- ------------------------------------------------------------
34.00 Row number 34
35.00 Row number 35
36.00 Row number 36
37.00 Row number 37
38.00 Row number 38
39.00 Row number 39
40.00 Row number 40
41.00 Row number 41
42.00 Row number 42
43.00 Row number 43
44.00 Row number 44
NUM_COL CHAR_COL
-------- ------------------------------------------------------------
45.00 Row number 45
46.00 Row number 46
47.00 Row number 47
48.00 Row number 48
49.00 Row number 49
50.00 Row number 50
50 rows selected.
SQL>
SQL> drop table MyTable;
Table dropped.
SQL>
SQL>
|