Ticker

6/recent/ticker-posts

PL/SQL Function Returning Boolean Validation in Oracle APEX - Javainhand Tutorial

PL/SQL Function Returning Boolean Validation in Oracle APEX

Hello Friends, In this Oracle APEX Tutorial, I will explain to you how to use PL/SQL Function Returning Boolean Validation in Oracle APEX.

Basically, PL/SQL Function Returning Boolean is a part of the validation type in Oracle APEX. In this Validation, you can write PL/SQL statement and function directly. It will return true when your condition is valid or if the condition is not valid then return false.

PL/SQL Function Body Returning Boolean Example

I have already posted a mobile number validation. Here I will take the same example for understanding about the PL/SQL Function Returning Boolean Validation.

Requirement :-Add validation for mobile number field that only accepts 10 digit only.

Step 1:-Create a Mobile Number Item P3_MOBILE_NUMBER. The below screenshot will help you.


Step 2:- Right-click on P3_MOBILE_NUMBER Item and create a validation. The below screenshot will help you.



Step 3:- After creating validation choose PL/SQL Function Returning Boolean Type the below screenshot and code will help you.
BEGIN 
    IF Length(Nvl(:P3_MOBILE_NUMBER, 0)) = 10 THEN 
      RETURN TRUE; 
    ELSE 
      RETURN FALSE; 
    END IF; 
END; 


Also using the function you can validate your condition.below code will help for better understand.
DECLARE 
    FUNCTION Validate_mobile_number(p_number IN NUMBER) 
    RETURN BOOLEAN 
    AS 
    BEGIN 
        IF Length(Nvl(p_number, 0)) = 10 THEN 
          RETURN TRUE; 
        ELSE 
          RETURN FALSE; 
        END IF; 
    END; 
BEGIN 
    IF Validate_mobile_number(:P3_MOBILE_NUMBER) THEN 
      RETURN TRUE; 
    ELSE 
      RETURN FALSE; 
    END IF; 
END; 
You can create your validation function into the database or in PL/SQL Function Returning Boolean Section Also.

Post a Comment

0 Comments