The following lines contain the word 'select', 'insert', 'update' or 'delete':
-252 Cost update to ic_perd_bal error.
<-252 Oracle RDBMS Error.
============================================= */
FUNCTION calc_costs(pwhse_code VARCHAR2,
pprd_end_date DATE,
pperiod NUMBER,
pfiscal_year VARCHAR2,
pop_code NUMBER)
RETURN NUMBER IS
/* Local Variable definitions and initialization:
============================================== */
l_iret NUMBER := 0;
CURSOR item_selection IS
SELECT DISTINCT(item_id)
FROM ic_perd_bal
WHERE fiscal_year = UPPER(pfiscal_year)
AND period = pperiod
AND whse_code = UPPER(pwhse_code)
AND loct_usage <> 0;
SELECT orgn_code
FROM ic_whse_mst
where whse_code = UPPER(pwhse_code)
AND delete_mark = 0;
OPEN item_selection;
FETCH item_selection INTO
l_item_id;
IF(item_selection%NOTFOUND) THEN
CLOSE item_selection;
WHILE (item_selection%FOUND) LOOP
/* Let's call the costing package
and determine the items cost.
============================== */
l_iret := 0;
/* Now let's update the perpetual balance
table for all occurances of the item.
====================================== */
UPDATE ic_perd_bal
SET loct_value = (loct_usage * l_cost),
last_update_date = SYSDATE,
last_updated_by = pop_code
WHERE fiscal_year = pfiscal_year
AND period = pperiod
AND whse_code = pwhse_code
AND item_id = l_item_id
AND loct_usage <> 0;
RETURN DEP_COST_UPDATE_ERR;
FETCH item_selection INTO
l_item_id;
CLOSE item_selection;