title: How does PLSQL function return text validation work?
body: <p>Unfortunately my validation doesn't work when i click a submit button. When I do click the submit button 'what' appears as error which is b = null below. How would you validate a registration page after the person presses the submit button. Or how would you do validation after submit button?</p>
  
  <pre><code>DECLARE
      error_message varchar2(4000);
      b varchar2(500); 
      FUNCTION validate_field RETURN VARCHAR2
      AS
          BEGIN
      b := :P101_REG_FIRST_NAME;
              IF (REGEXP_LIKE(b, '[A-Za-z]') AND :P101_NEW &lt;&gt; NULL AND NOT(REGEXP_LIKE(b, '[:space:]'))) THEN
                  RETURN 'works' || b;
  
              ELSIF b IS NULL THEN
                  RETURN b || 'what';
  
              ELSIF REGEXP_COUNT(b, '[A-Za-z]')  = 1 THEN 
                  RETURN 'Name cannot be single letter';
  
                  ELSE RETURN 'HUH' || ' ' || b;
              END IF;
          END;
  
  
          BEGIN
              error_message := '';
              error_message := validate_field;
  
              IF error_message IS NULL THEN
                  RETURN NULL;
              ELSE
                  RETURN error_message;
              END IF;
          COMMIT;
          END;
  </code></pre>