요일과 시간 제한두는 프로시저

양혜정·2024년 3월 25일

Oracle

목록 보기
47/49

요일명 월,화,수,목,금 오후 2시~ 오후 5시(정각은 안됨)

create or replace procedure pcd_tbl_member_test1_insert
(p_userid IN tbl_member_test1.userid%type
,p_passwd IN tbl_member_test1.passwd%type
,p_name IN tbl_member_test1.name%type
)
is
	error_dayTime	exception;		-- error 변수 선언
    v_passwd_length	number(2);
    error_insert	exception;		-- error 변수 선언
    v_ch			varchar2(1);	-- passwd 글자 한개
    v_flag_alphabet	number(1) := 0;	-- 영문자 확인 용도
    v_flag_number	number(1) := 0;	-- 숫자 확인 용도
    v_flag_special	number(1) := 0;	-- 특수문자 확인 용도
begin
	if(to_char(sysdate,'d') in ('1','7') 
    or to_number(to_char(sysdate, 'hh24')) < 14
    or to_number(to_char(sysdate, 'hh24')) > 16)
    then raise error_dayTime;
    else
    	v_passwd_length := length(p_passwd);
        if(v_passwd_length < 5 or v_passwd_length > 20) then raise
        											error_insert;
        else
        	For i in 1.. v_passwd_length LOOP
            v_ch := substr(p_passwd,i,1);
            
           if(v_ch between 'A' and 'Z') or (v_ch between 'a' and 'z')
           then v_flag_alphabet := 1;
           elsif(v_ch between '0' and '9') then v_flag_number := 1;
           else v_flag_special := 1;
           end if;
           END LOOP;
           
           if(v_flag_alphabet * v_flag_number * v_flag_special = 1)
           then insert into tbl_member_test1(userid, passwd, name)
           values(p_userid, p_passwd, p_name);
           else raise error_insert;
           end if;
      end if;
	end if;
    Exception
    WHEN error_dayTime THEN raise_application_error(-20003, 
    '>> 영업시간(월~금 14:00 ~ 16:59:59 까지)이 아니므로 입력불가함 <<');
    WHEN error_insert THEN raise_application_error(-20002,
    '>> 암호는 최소 5글자 이상이면서 영문자 및 숫자 및 특수기호가 
    									혼합되어져야 합니다. <<');
end pcd_tbl_member_test1_insert;

0개의 댓글