Function For String Handling

Description: This ‘AndNotStr’ Function is intended to check a string to see if it contains one nested element but does not contain a second nested element.

CREATE OR REPLACE FUNCTION  AndNotStr (
evalstr VARCHAR2,
str1in VARCHAR2,
str2in VARCHAR2)
RETURN NUMBER IS
 
x BOOLEAN := FALSE;
NoGood EXCEPTION;
 
BEGIN
   IF INSTR(evalstr, str1in, 1, 1) = 0 THEN
      RAISE NoGood;
   END IF;
 
   IF INSTR(evalstr, str2in, 1, 1) > 0 THEN
      RAISE NoGood;
   END IF;
 
   RETURN 1;
 
EXCEPTION
   WHEN NoGood THEN
      RETURN 0;
 
END AndNotStr;
/

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.