你能帮我写一个PLSQL代码来传递一个变量的'多个输入值'吗?请帮助我如何使用Record类型,对象和构造函数来编写Anonymous PLSQL块。
谢谢,
此致 Veeresh
答案 0 :(得分:0)
以下是一种方式:
HR@XE> CREATE OR REPLACE TYPE NUM_ARRAY AS TABLE OF NUMBER;
2 /
Type created.
HR@XE> create or replace procedure demo_sp (
in_array in num_array,
out_sum out number
)
is
BEGIN
out_sum := 0;
for i in 1 ..in_array.count loop
out_sum := out_sum + in_array(i);
END LOOP;
END;
/
Procedure created.
HR@XE> DECLARE
total NUMBER;
nos NUM_ARRAY;
BEGIN
SELECT ROWNUM BULK COLLECT INTO nos FROM dual CONNECT BY ROWNUM<=5;
FOR I IN 1 .. nos.COUNT LOOP
dbms_output.put_line(nos(i));
end loop;
demo_sp(nos,total);
dbms_output.put_line('Total is: '||total);
END;
/
1
2
3
4
5
Total is: 15
PL/SQL procedure successfully completed.
HR@XE>