我创建了一个接受用户类型作为输入的过程。任何人都可以让我知道如何通过蟾蜍执行相同的操作? TYPE和PROCEDURE详细信息如下。
CREATE OR REPLACE TYPE CER_GL_ENTRY_TYPE AS OBJECT
(idKey NUMBER (3),
shortName VARCHAR2 (15),
fmrCusip VARCHAR2 (15),
incorrectTrdShares NUMBER (10),
incorrectTrdPrice NUMBER (10, 2),
incorrectTrdBuySell VARCHAR2 (15),
incorrectTrdCommRate NUMBER (10, 2),
incorrectTrdCommission NUMBER (10, 2),
incorrectTrdFees NUMBER (10, 2),
incorrectTrdNet NUMBER (10, 2),
correctionTrdShares NUMBER (10, 2),
correctionTrdPrice NUMBER (10, 2),
correctionTrdBuySell VARCHAR2 (15),
correctionTrdCommRate NUMBER (10, 2),
correctionTrdCommission NUMBER (10, 2),
correctionTrdFees NUMBER (10, 2),
correctionTrdNet NUMBER (10, 2),
currency VARCHAR2 (15),
fx VARCHAR2 (15),
netUSD NUMBER (10, 2),
notes VARCHAR2 (15)
);
CREATE or REPLACE TYPE CER_GL_ENTRY_TYPE_LIST AS TABLE OF CER_GL_ENTRY_TYPE;
CREATE OR REPLACE PROCEDURE GL_PROCESS_BULK_ENTRIES (p_array IN CER_GL_ENTRY_TYPE_LIST, p_status out varchar2)
AS
v_count NUMBER;
row_detail CER_GL_ENTRY_TYPE;
BEGIN
--p_arr_int := NEW array_int ();
--p_arr_int.EXTEND (10);
--len := p_array.COUNT;
v_count := 0;
FOR i IN 1 .. p_array.COUNT
LOOP
row_detail := p_array(i);
DBMS_OUTPUT.put_line (row_detail.idKey);
--p_arr_int (i) := v_count;
v_count := v_count + 1;
p_status := 'true';
END LOOP;
DBMS_OUTPUT.put_line (v_count);
DBMS_OUTPUT.put_line (p_status);
EXCEPTION
WHEN OTHERS THEN
-- handle errors here...
dbms_output.put_line('Error: '||substr(1,255,sqlerrm));
END;
/
有谁能告诉我如何执行GL_PROCESS_BULK_ENTRIES程序?
答案 0 :(得分:1)
例如,将一些随机数据分配给表格:
SQL> set serverout on
SQL> declare
2 t_mytab CER_GL_ENTRY_TYPE_LIST := CER_GL_ENTRY_TYPE_LIST();
3 v_status varchar2(10);
4 begin
5
6 for idx in 1..10 loop
7 t_mytab.extend;
8 t_mytab(t_mytab.last) := CER_GL_ENTRY_TYPE(idx, 'x', 'x', 0, 1, 'x', 1, 1, 1, 1, 1, 1, 'x', 1, 1, 1, 1, 'x', 'x', 2, 'foo');
9 end loop;
10
11 GL_PROCESS_BULK_ENTRIES(t_mytab, v_status);
12
13 end;
14 /
1
2
3
4
5
6
7
8
9
10
10
true
PL/SQL procedure successfully completed.
或者你可以,如果你有一个静态列表,只需分配一个:
SQL> declare
2 t_mytab CER_GL_ENTRY_TYPE_LIST := CER_GL_ENTRY_TYPE_LIST();
3 v_status varchar2(10);
4 begin
5
6 t_mytab := CER_GL_ENTRY_TYPE_LIST(
7 CER_GL_ENTRY_TYPE(123, 'x', 'x', 0, 1, 'x', 1, 1, 1, 1, 1, 1, 'x', 1, 1, 1, 1, 'x', 'x', 2, 'foo'),
8 CER_GL_ENTRY_TYPE(2, 'x', 'x', 0, 1, 'x', 1, 1, 1, 1, 1, 1, 'x', 1, 1, 1, 1, 'x', 'x', 2, 'foo')
9 );
10
11 GL_PROCESS_BULK_ENTRIES(t_mytab, v_status);
12
13 end;
14 /
123
2
2
true