2016-07-07 3 views
2

를 작동하지 않는 나는 다음과 같은 코드를 가지고 :PL/SQL 정규 표현식

declare 
    l_input  clob; 
    l_output  clob; 
    function check_this_regex(
    io_str in out clob 
    ,o_found out clob 
) return boolean 
    is 
    l_match clob; 
    begin 
    dbms_output.put_line('Matching against ->' || io_str || '<-'); 
    l_match := regexp_substr(io_str, '"((y)*)"'); 

    if l_match is null then 
     return false; 
    end if; 

    o_found := l_match; 
    return true; 
    end; 
begin 
    l_input := to_clob('x'); 
    dbms_output.put_line('l_input->' || l_input || '<-'); 
    if (check_this_regex(l_input, l_output)) then 
    dbms_output.put_line('Found: ' || l_output); 
    else 
    dbms_output.put_line('Not found'); 
    end if; 
end; 

왜이 출력 Found합니까?

답변

3

문제는 클로브를 NULL에 대해 확인해야합니다. 수표 이런 식으로

if l_match /* is null */ = empty_clob() then 

을 편집하면 제공 : CLOB에 대한

l_input->x<- 
Matching against ->x<- 
Not found 
+0

완벽합니다. - 감사합니다. –

0

REGEXP_SUBSTR가 alwas NOT NULL value.Check 예를 반환합니다.

declare 
v_clob clob; 
v_in clob :='a'; 

v_str varchar2(10); 
v_st_in varchar2(10) :='a'; 
begin 
v_clob := regexp_substr(v_in,'xx'); 
if v_clob is null then 
    dbms_output.put_line('aaa'); 
end if; 
v_str := regexp_substr(v_st_in,'xx'); 
if v_str is null then 
    dbms_output.put_line('aaa'); 
end if; 
end;