Sunday, December 19, 2010

IF-THEN-ELSIF-ELSE-END IF statement with Logical Operators

SET VERIFY OFF
SET SERVEROUTPUT ON
DECLARE
    v_char CHAR(1) := '&user_input';
BEGIN
    IF ( v_char >= 'A'  AND v_char <= 'Z') OR  ( v_char >= 'a'  AND v_char <= 'z')  THEN
        DBMS_OUTPUT.PUT_LINE('User input is a letter');
    ELSIF ( v_char >= '0' and v_char <= '9' ) THEN
        DBMS_OUTPUT.PUT_LINE('User input is a number');
    ELSE
         DBMS_OUTPUT.PUT_LINE('User input is a special Character');
   END IF;
END;
/
Enter value for user_input: A
User input is a letter

PL/SQL procedure successfully completed.
SQL> /
Enter value for user_input: 3
User input is a number

PL/SQL procedure successfully completed.
SQL> /
Enter value for user_input: $
User input is a special Character

PL/SQL procedure successfully completed.

No comments:

Post a Comment

External Table

Oracle External Table External tables are defined as tables that do not resides in the database allows you to access data that is stor...