Saturday, 11 October 2014

In oracle forms i want to check in text field that is check whether user entered only number values or not for example phone number or tin number or zip code  so on....

Hear is the code to check whether user entered only numeric value or not using  PL/SQL code?

CREATE OR REPLACE FUNCTION NUMBER_CHECK (P_INPUT VARCHAR2)
    RETURN   NUMBER IS
    v_i      NUMBER := 0;
    v_length NUMBER := 0;
    v_select VARCHAR2(10);
    v_count  NUMBER := 0;
    v_return NUMBER;
    BEGIN
    v_length := length(P_INPUT);
    LOOP
     v_i :=  v_i + 1;
        SELECT  SUBSTR(p_input,v_i, 1)
        INTO    v_select
        FROM    dual;
        SELECT COUNT(*)
        INTO   v_count
        FROM   faaccountmaster
        WHERE REGEXP_LIKE (v_select,'[0-9]');
        IF  v_count = 0 THEN
            v_return  := 0;
            EXIT;
        ELSE
            v_return  := 1;
        END IF;
        IF v_i = v_length THEN
           EXIT;
        END IF;
    END LOOP;
    RETURN v_return;
    END NUMBER_CHECK;

Copyright © ORACLE-FORU - SQL, PL/SQL and ORACLE D2K(FORMS AND REPORTS) collections | Powered by Blogger
Design by N.Design Studio | Blogger Theme by NewBloggerThemes.com