/*TO SELECT APPROPRIATE INDEX NUMBER(ftvacci_acci_code) FROM INDEX TABLE 
BASED ON ASSIGNED COA, FUND, ORGN, PROG FROM BUDGET LABOR DISTRIBUTION (nbrplbd) 
WHERE INDEX IS MISSING FROM (nbrplbd)*/ 

SELECT ftvacci_acci_code, nbrplbd_posn
FROM nbrplbd, ftvacci
WHERE nbrplbd_fisc_code = '&FISCAL_YR'
AND nbrplbd_acci_code IS NULL
AND nbrplbd_coas_code = '1'
AND nbrplbd_coas_code = ftvacci_coas_code
AND nbrplbd_fund_code = ftvacci_fund_code
AND nbrplbd_orgn_code = ftvacci_orgn_code
AND nbrplbd_prog_code = ftvacci_prog_code
AND ftvacci_status_ind = 'A' 
AND ftvacci_eff_date < SYSDATE 
AND ftvacci_term_date IS NULL
AND (ftvacci_nchg_date >= SYSDATE OR ftvacci_nchg_date IS NULL)
ORDER BY nbrplbd_posn;


