Valid Email Check using oracle PL/SQL



declare
v_email varchar2(50):='hhhhhla@gmail.com';
v_1 varchar2(1);
v_count number;
v_2 number:=1;
a varchar2(50);
begin
select length(substr(v_email,-(length(v_email)),instr(v_email,'.',1,1))) len into v_count from dual;
loop
v_1:=substr(v_email,v_2,1);
a:=a||substr(v_email,v_2,1);
v_2:=length(a)+1;
if v_1='@' then
exit;
elsif v_2>v_count then
exit;
end if;
end loop;
if v_1='@' then
dbms_output.put_line('valid email');
elsif v_1<>'@' then
dbms_output.put_line('not valid email');
end if;
end;




create or replace function valid_mail2(v_email varchar2) return varchar2 as
v_1 varchar2(1);
v_count number;
v_2 number:=1;
a varchar2(50);
begin
v_count:=length(v_email);
for i in 1..v_count loop
v_1:=substr(v_email,v_2,1);
a:=a||substr(v_email,v_2,1);
v_2:=length(a)+1;
if v_1='.' then
exit;
elsif v_2>v_count then
exit;
end if;
end loop;
if v_1='.' then
declare
v_1 varchar2(1);
v_count number;
v_2 number:=1;
a varchar2(50);
begin
select length(substr(v_email,-(length(v_email)),instr(v_email,'.',1,1))) len into v_count from dual;
loop
v_1:=substr(v_email,v_2,1);
a:=a||substr(v_email,v_2,1);
v_2:=length(a)+1;
if v_1='@' then
exit;
elsif v_2>v_count then
exit;
end if;
end loop;
if v_1='@' then
return 1;
elsif v_1<>'@' then
return 0;
end if;
end;
elsif v_1<>'.' then
declare
v_1 varchar2(1);
v_count number;
v_2 number:=1;
a varchar2(50);
begin
v_count:=length(v_email);
loop
v_1:=substr(v_email,v_2,1);
a:=a||substr(v_email,v_2,1);
v_2:=length(a)+1;
if v_1='@' then
exit;
elsif v_2>v_count then
exit;
end if;
end loop;
if v_1='@' then
return 1;
elsif v_1<>'@' then
return 0;
end if;
end;
end if;
end;

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন