lpdql declare
type num_varray is varray(100) of number;
v_num_varray num_varray;
begin
for j in 1..100
loop
v_num_varray:=num_varray(j);
end loop;
for i in 1..v_num_varray.count
loop
dbms_output.put_line(to_char(v_num_varray(i)));
end loop;
end;
结果:100
我的目的结果:从1到100
如何改写?
oracle?plsqlplsql
------解决方案--------------------
DECLARE
TYPE NUM_VARRAY IS VARRAY(100) OF NUMBER NOT NULL;
V_NUM_VARRAY NUM_VARRAY:=NUM_VARRAY();
BEGIN
FOR J IN 1 .. 100 LOOP
V_NUM_VARRAY.EXTEND;
V_NUM_VARRAY(J) := J;
END LOOP;
FOR I IN 1 .. V_NUM_VARRAY.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(TO_CHAR(V_NUM_VARRAY(I)));
END LOOP;
END;