Sunday, December 19, 2010

IF-THEN-ELSE-END IF Statement

/*  Test user provided numbe is even or odd */
SET SERVEROUTPUT ON
SET VERIFY OFF
DECLARE
 v_user_input  NUMBER  := &user_input;
BEGIN
 -- Test user provided number is even
 IF  MOD(v_user_input, 2)   = 0 THEN
  DBMS_OUTPUT.PUT_LINE( v_user_input || ' is  a even number');
 ELSE
  DBMS_OUTPUT.PUT_LINE( v_user_input || ' is  a odd number');
 END IF;
END;
/
Enter value for user_input: 23
23 is  a odd number

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...