Monday, December 27, 2010

Searched Case Statement

SET SERVEROUTPUT ON
SET VERIFY OFF
DECLARE
  v_user_date DATE := TO_DATE('&user_date','DD-MON-YYYY');
BEGIN
  CASE
    WHEN TO_CHAR(v_user_date,'D') = '1' THEN
      dbms_output.put_line('Today is Monday');
    WHEN TO_CHAR(v_user_date,'D') = '2' THEN
      dbms_output.put_line('Today is Tuesday');
    WHEN TO_CHAR(v_user_date,'D') = '3' THEN
      dbms_output.put_line('Today is Wednesday');
    WHEN TO_CHAR(v_user_date,'D') = '4' THEN
      dbms_output.put_line('Today is Thursday');
    WHEN TO_CHAR(v_user_date,'D') = '5' THEN
      dbms_output.put_line('Today is Friday');
    WHEN TO_CHAR(v_user_date,'D') = '6' THEN
      dbms_output.put_line('Today is Saturday');
    WHEN TO_CHAR(v_user_date,'D') = '7' THEN
      dbms_output.put_line('Today is Sunday');
  END CASE;
END;
/
Enter value for user_date: 01-JAN-2012
Today is Sunday

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