procedure add_wk(pi_prod_name varchar2,
pi_ctry varchar2,
pi_sid varchar2,
pi_user varchar2,
pi_qty number) is
--Deklarationsteil
l_ref_temp number; --tempvar
l_wkref number; --referer
l_check_wk varchar2(10); --prüfvar
l_check_pos varchar2(10);
l_wknumber number;
v_lastlevel number;
v_lastsequence number;
v_seq number;
v_temp number;
v_level number;
v_arraytemp number;
sq number;
type a_array is table of number index by binary_integer;
v_array a_array;
Cursor c_wk_struct is
select 0 ll, pi_prod_name opt_name
from dual
union all
select ll, opt_name
from (select level ll, opt_name
from t_pdz_must_opt_z m
where m.opt_class in ('FIX', 'DEF')
connect by m.prod_name = prior m.opt_name
and m.opt_class in ('FIX', 'DEF')
start with m.prod_name = pi_prod_name) opts,
t_pdz_product_z p
where opts.opt_name = p.prod_name
and p.conf_flag = 'O';
begin
--Check if n_array have no elements.
-----array vor start leeren !
for f_rec in c_wk_struct loop
v_level := f_rec.ll;
dbms_output.put_line('levelbereich:' || v_level);
if v_level > v_lastlevel then
v_array(v_level) := v_lastsequence;
v_temp := v_array(v_level);
end if;
dbms_output.put_line('v_array:' || v_temp);
insert into t_www_wk_pos
(sid, sq_no, prod_name, opt_flag, datum, referer)
select pi_sid, s_www_wk.nextval, d.prod_name, null, sysdate, v_temp
from t_pdz_product_diff d
where d.prod_name = f_rec.opt_name
and d.ctry_code = 'XD'
and f_rec.opt_name = pi_prod_name;
insert into t_www_wk_pos
(sid, sq_no, prod_name, opt_flag, datum, referer)
select pi_sid,
s_www_wk.nextval,
m.opt_name,
m.opt_class,
sysdate,
v_temp
from t_must_opt m, t_pdz_product_z z, t_pdz_product_diff d
where m.prod_name = f_rec.opt_name
and m.prod_name = z.prod_name
and m.opt_name = d.prod_name
and d.ctry_code = 'XD'
and z.conf_flag != 'o'
and m.opt_class in ('FIX', 'DEF');
dbms_output.put_line('testsq:' || v_seq);
v_lastlevel := v_level;
v_lastsequence := v_seq;
dbms_output.put_line(v_level || ' ' || f_rec.opt_name || ' ');
end loop;
commit;
end;