ORACLE儲存過程判斷非法字元

2021-08-30 09:58:24 字數 1956 閱讀 7191

---------------------------呼叫方法

--驗證非法字元

ismg := fun_issensitivity(v_arr);

if not ismg then

v_sendmsg := '很好,你的資訊是正常的。';

else

v_sendmsg := '對不起,您的資訊含有敏感字,請修改後再發!';

end if;

---------------------------中間過程

create or replace function fun_issensitivity(arr in splitlongstr) return boolean is

result boolean;

i number;

v_mg_msg varchar2(4000);

begin

i:=1;

result:=false;

while (i<=arr.count) loop

syn_sp_unlawful(arr(i),v_mg_msg);

v_mg_msg:=replace(v_mg_msg,' ','');

if v_mg_msg='0' then

null;

else

result:=true;

exit;

end if;

i:=i+1;

end loop;

return(result);

end fun_issensitivity;

--------------------------敏感字元判斷過程

create or replace procedure sp_unlawful

( in_msg in varchar2,

out_msg out varchar2

) is

/* 敏感字元判斷過程

*/ v_result varchar2(1024);

v_location number;

v_word varchar2(1024);

v_i number;

cursor c_unlawful is

select msg

from word_unlawful

where is_valid=1;

begin

v_i:=0;

open c_unlawful;

loop

fetch c_unlawful into v_word;

exit when c_unlawful%notfound;

select instr(in_msg,v_word) into v_location

from dual;

if v_location>0 then

v_i:=v_i+1;

v_result:=v_result||','||v_word;

end if;

end loop;

close c_unlawful;

if v_i>0 then

out_msg:=ltrim(v_result,',');

else

out_msg:='0';

end if;

end sp_unlawful;

------------------------------建立收集的非法字元列表

-- create table

create table word_unlawful

( msg varchar2(100) not null,

is_valid number(1) not null,

ins_date date default sysdate not null

);

oracle判斷日期函式 儲存過程例子

一 判斷日期函式例子 sql create or replace function is date parmin varchar2 2 return number 3 is 4 val date 5 begin 6 val to date nvl parmin,a yyyy mm dd hh24 m...

oracle儲存過程判斷值是否相等

問題1 左右值為null使用等號進行比較的情況 created on 2021 03 16 by kuroisheep declare i integer j integer begin if i j then dbms output.put line 相等 else dbms output.put...

Oracle儲存過程呼叫儲存過程

oracle儲存過程呼叫有返回結果集的儲存過程一般用光標的方式,宣告乙個游標,把結果集放到游標裡面,然後迴圈游標 declare newcs sys refcursor cs1 number cs2 number cstype table rowtype table列的個數和newcs返回的個數一樣...