I was trying to create a function in pl/sql that will accept a String and to split the String into an array then compare the array of the split string into the invalid characters stored in the database.
I am still experimenting, haven't tested the apex_string.split since I encountered these errors: Error(7,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function pragma procedure subtype type current cursor delete exists prior The symbol "begin" was substituted for "DECLARE" to continue.
Error(38): PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge
I'm kinda new to PL/SQL and I am open to any comments
thanks
create or replace FUNCTION invalid_checker(inword IN varchar2)
RETURN boolean
IS
hasInvalid boolean;
declare
CURSOR invalids IS select invalidChar from InvalidCharacter; --table that contains the invalid characters
Type wordsplit IS VARRAY(100) OF VARCHAR2(2);
splitcount INTEGER;
invalidscount INTEGER ;
ctr INTEGER := 0;
invalidctr INTEGER :=0;
wordarray wordsplit;
begin
open invalids;
wordarray := wordsplit(apex_string.split(inword, null));--split inserted word into array
--splitcount := wordsplit.count
--invalidsctr := invalids.count
FOR splitcount IN wordarray LOOP
ctr := ctr + 1;
FOR invalidscount IN invalids LOOP
invalidctr := invalidctr + 1;
IF (wordarray(ctr) = invalids(invalidctr)) THEN
hasInvalid := true;
END IF;
END LOOP;
END LOOP;
close invalids;
RETURN hasInvalid;
end;
/
declare, it's not needed.