Use IN operator in procedure : IN « PL SQL « Oracle PL / SQL

Oracle PL / SQL
1. Aggregate Functions
2. Analytical Functions
3. Char Functions
4. Constraints
5. Conversion Functions
6. Cursor
7. Data Type
8. Date Timezone
9. Hierarchical Query
10. Index
11. Insert Delete Update
12. Large Objects
13. Numeric Math Functions
14. Object Oriented Database
15. PL SQL
16. Regular Expressions
17. Report Column Page
18. Result Set
19. Select Query
20. Sequence
21. SQL Plus
22. Stored Procedure Function
23. Subquery
24. System Packages
25. System Tables Views
26. Table
27. Table Joins
28. Trigger
29. User Previliege
30. View
31. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL / SQL » PL SQL » IN 
Use IN operator in procedure
  


SQL>
SQL>
SQL>
SQL> -The IN operator used to test for long weekends.
SP2-0734: unknown command beginning "-The IN op..." - rest of line ignored.
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  2     test_date     DATE;
  3     day_of_week   VARCHAR2(3);
  4     years_ahead   INTEGER;
  5  BEGIN
  6     --Assign a date value to test_date.
  7
  8     test_date := TO_DATE('4-Jul-1997','dd-mon-yyyy');
  9
 10     FOR years_ahead IN 1..10 LOOP
 11       day_of_week := TO_CHAR(test_date,'Dy');
 12
 13      IF day_of_week IN ('Mon','Fri','Sat','Sun') THEN
 14          DBMS_OUTPUT.PUT_LINE(TO_CHAR(test_date,'dd-Mon-yyyy')|'     long weekend!');
 15       ELSE
 16           DBMS_OUTPUT.PUT_LINE(TO_CHAR(test_date,'dd-Mon-yyyy')|' Not a long weekend.');
 17       END IF;
 18       --Advance one year (12 months)
 19       test_date := ADD_MONTHS(test_date,12);
 20    END LOOP;
 21  END;
 22  /
04-Jul-1997     long weekend!
04-Jul-1998     long weekend!
04-Jul-1999     long weekend!
04-Jul-2000 Not a long weekend.
04-Jul-2001 Not a long weekend.
04-Jul-2002 Not a long weekend.
04-Jul-2003     long weekend!
04-Jul-2004     long weekend!
04-Jul-2005     long weekend!
04-Jul-2006 Not a long weekend.

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>
           
         
    
  
Related examples in the same category
1. IN operator in PL SQL
2. IN operator checks whether a variable value is in a set of comma-delimited values.
3. IN/NOT IN example(table collection)
4. NOT IN example (table collection)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.