CREATE or replace FUNCTION WHATSAPP_KOSUL(PSIRKET_KOD NUMBER,PKOD VARCHAR2,PKELIME VARCHAR2) RETURN NUMBER IS
cursor c1 is
 select a.kelime,a.icerir
 from nakliye.whatsapp_kritik_detay_table a
 where a.sirket_kod=1
 and a.kod=pkod
 and a.kelime is not null;
kayit c1%rowtype; 
xbir number;
BEGIN
  if trim(PKELIME) is null then
     return(0);
  end if;   
   open c1;
   loop
     fetch c1 into kayit;
     exit when (c1%notfound);
     if kayit.icerir='E' then
       begin
       select 1 into xbir
       from dual
       where regexp_like(pkelime,Translate(kayit.kelime,'i','..............'),'i');
       exception
         when no_data_found then 
           close c1;
           return(0);
       end;
     else
       begin
       select 1 into xbir
       from dual
       where regexp_like(pkelime,Translate(kayit.kelime,'i','..............'),'i');
       close c1;
       return(0);
       exception
         when no_data_found then 
           null;
       end;
     end if;
   
   end loop;
   close c1;


 RETURN(1);
END;

