將 Type 宣告為數字表 (38,0)。在函式的程序中。
代碼示例:
ids_list := Type(....); // load data to variable
ids_list.trim(count);
我不太明白如何修剪帶有數字引數的數字串列的串列。ids_list.trim(count) 會發生什么?
uj5u.com熱心網友回復:
如果我理解正確的話,你說的是一個集合及其trim方法。如果是這樣,那么檔案說:
減小集合的大小(TRIM 方法)
這個程序有兩種形式:
TRIM 從集合的末尾洗掉一個元素。
TRIM(n) 從集合的末尾洗掉 n 個元素。
如果要洗掉所有元素,請使用不帶引數的 DELETE。
您發布的代碼沒有做任何事情,因為
SQL> declare
2 type numlist is table of number;
3 n numlist := numlist(1,2,3, 10);
4 begin
5 n.trim(count);
6 end;
7 /
n.trim(count);
*
ERROR at line 5:
ORA-06550: line 5, column 10:
PLS-00204: function or pseudo-column 'COUNT' may be used inside a SQL statement only
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored
SQL>
也許您打算改用該count方法 ( n.count)?
SQL> declare
2 type numlist is table of number;
3 n numlist := numlist(1,2,3, 10);
4 begin
5 dbms_output.put_line('Number of elements in that collection = ' || n.count);
6
7 n.trim(n.count);
8
9 dbms_output.put_line('Number of elements in that collection AFTER trim = ' || n.count);
10 end;
11 /
Number of elements in that collection = 4
Number of elements in that collection AFTER trim = 0
PL/SQL procedure successfully completed.
SQL>
如果是這樣,那么 - 正如您所看到的 - 它會從集合中洗掉所有元素。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/314305.html
