Oracle plsql集合中的扩展方法
这是节目Oracle plsql集合中的扩展方法,oracle,plsql,Oracle,Plsql,这是节目 DECLARE TYPE t1 IS TABLE OF NUMBER(10); v_t t1 := t1(10,20,30,40); BEGIN dbms_output.put_line(v_t.first); dbms_output.put_line(v_t.last); dbms_output.put_line(v_t.PRIOR(2) ); dbms_output.put_line(v_t.nex
DECLARE
TYPE t1 IS
TABLE OF NUMBER(10);
v_t t1 := t1(10,20,30,40);
BEGIN
dbms_output.put_line(v_t.first);
dbms_output.put_line(v_t.last);
dbms_output.put_line(v_t.PRIOR(2) );
dbms_output.put_line(v_t.next(2) );
v_t.extend;
v_t.extend(2);
v_t.extend(3,2);
v_t(5) := 50;
v_t(6) := 60;
v_t(7) := 70;
v_t.trim;
dbms_output.put_line(v_t.count);
FOR i IN v_t.first..v_t.last LOOP
dbms_output.put_line(v_t(i) );
END LOOP;
END;
/
输出:
这里我无法理解这个程序的输出,请任何人解释一下这个输出。
提前谢谢
1 = dbms_output.put_line(v_t.first) - returns the first subscript/index value of
t1(10,20,30,40) which is 1
4 = dbms_output.put_line(v_t.last) - returns the last subscript/index value of
t1(10,20,30,40) which is 4
1 = dbms_output.put_line(v_t.PRIOR(2)) - returns the subscript that precedes index n in a
collection which is 1.
3 = dbms_output.put_line(v_t.next(2)) - returns the subscript that succeeds index n in a
collection which is 3.
9 = dbms_output.put_line(v_t.count) - v_t.EXTEND appends one null element to the collection, v_t.EXTEND appends 2 null elements to the collection and v_t.EXTEND(3,2) appends 3 copies of the 2nd element to the collection
10 = dbms_output.put_line(v_t(i) - Prints all the elements.
20
30
40
50
60
70
20 = v_t.extend(3,2) - Added 3 copies of 2nd element which is 20
20 = v_t.extend(3,2) - ""
第三份副本(20)被排除在外,因为v_t.trim从集合末尾删除了一个元素您没有明确理解哪一部分?请仔细阅读文档以了解收集方法:感谢您宝贵的解释
1 = dbms_output.put_line(v_t.first) - returns the first subscript/index value of
t1(10,20,30,40) which is 1
4 = dbms_output.put_line(v_t.last) - returns the last subscript/index value of
t1(10,20,30,40) which is 4
1 = dbms_output.put_line(v_t.PRIOR(2)) - returns the subscript that precedes index n in a
collection which is 1.
3 = dbms_output.put_line(v_t.next(2)) - returns the subscript that succeeds index n in a
collection which is 3.
9 = dbms_output.put_line(v_t.count) - v_t.EXTEND appends one null element to the collection, v_t.EXTEND appends 2 null elements to the collection and v_t.EXTEND(3,2) appends 3 copies of the 2nd element to the collection
10 = dbms_output.put_line(v_t(i) - Prints all the elements.
20
30
40
50
60
70
20 = v_t.extend(3,2) - Added 3 copies of 2nd element which is 20
20 = v_t.extend(3,2) - ""