
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;
---Added by chandrashekar on 06-08-2014 start
create  or replace function get_cycle_criteria(as_site_code char, as_item_code char)
return char is as_cyclecriteria char ;
begin
begin

select cycle_criteria into as_cyclecriteria 
from siteitem
where site_code = as_site_code
and item_code = as_item_code;


if trim(as_cyclecriteria) is null then 

select cycle_criteria into as_cyclecriteria
from item
where  item_code = as_item_code;
return as_cyclecriteria;
else
return as_cyclecriteria;
end if;

exception 
 when no_data_found then
 
 select cycle_criteria into as_cyclecriteria
from item
where  item_code = as_item_code;
return as_cyclecriteria;
end;

 return  as_cyclecriteria;
end;
---End Added by chandrashekar on 06-08-2014
