Impact of EXIT in a function
SQL>
SQL> -- Impact of EXIT in a function.
SQL>
SQL> CREATE OR REPLACE FUNCTION exitfunc(p_pass_string VARCHAR2)
2 RETURN NUMBER IS
3 len Number := 1;
4 BEGIN
5 WHILE len <= LENGTH(p_PASS_STRING) LOOP
6 len := len + 1;
7 EXIT WHEN SUBSTR(p_PASS_STRING,len,1) = ' ';
8 END LOOP;
9 RETURN len ;
10 END exitfunc;
11 /
Function created.
SQL>
SQL>
SQL> -- Executing EXIT within a function.
SQL> DECLARE
2 v_MYTEXT VARCHAR2(20) := 'THIS IS A TEST';
3 BEGIN
4 DBMS_OUTPUT.PUT_LINE('Total count is ' || exitfunc(v_MYTEXT));
5 END;
6 /
Total count is 5
PL/SQL procedure successfully completed.
SQL>
Related examples in the same category