SQL>
SQL> -- The WHILE loop as part of a function.
SQL>
SQL> CREATE OR REPLACE FUNCTION noSpaceF(p_pass_string VARCHAR2)
2 RETURN NUMBER IS
3 counter INTEGER := 1;
4 v_return NUMBER := 0;
5 BEGIN
6 WHILE counter <= LENGTH(p_PASS_STRING) LOOP
7 IF SUBSTR(p_PASS_STRING,counter,1) != ' ' THEN
8 v_return := v_return + 1;
9 ELSE
10 NULL;
11 END IF;
12 counter := counter + 1;
13 END LOOP;
14 RETURN v_return;
15 END noSpaceF;
16 /
Function created.
SQL>
SQL> select noSpaceF('www.java2s.com www.java2s.com') from dual;
NOSPACEF('WWW.JAVA2S.COMWWW.JAVA2S.COM')
----------------------------------------
28