
ALTER TABLE SITEITEM ADD ANALYSIS_CLASS   CHAR(1);

ALTER TABLE SITEITEM ADD CYCLE_CRITERIA   CHAR(1);

create  or replace function get_analysis_class(as_site_code char, as_item_code char)
return char is as_anal_class char ;
begin
begin

select analysis_class into as_anal_class 
from siteitem
where site_code = as_site_code
and item_code = as_item_code;


if trim(as_anal_class) is null then 

select analysis_class into as_anal_class
from item
where  item_code = as_item_code;
return as_anal_class;
else
return as_anal_class;
end if;

exception 
 when no_data_found then
 
 select analysis_class into as_anal_class
from item
where  item_code = as_item_code;
return as_anal_class;
end;

 return  as_anal_class;
end;
