Declaring a Condition and Handler in action : Condition HANDLER « Procedure Function « SQL / MySQL

SQL / MySQL
1. Backup Load
2. Command MySQL
3. Cursor
4. Data Type
5. Database
6. Date Time
7. Flow Control
8. Function
9. Insert Delete Update
10. Join
11. Key
12. Math
13. Procedure Function
14. Select Clause
15. String
16. Table Index
17. Transaction
18. Trigger
19. User Permission
20. View
21. Where Clause
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
Oracle PL/SQL Tutorial
PostgreSQL
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
SQL / MySQL » Procedure Function » Condition HANDLER 
Declaring a Condition and Handler in action
 
mysql>
mysql>
mysql> DELIMITER //
mysql>
mysql> CREATE FUNCTION perform_logic (some_input INT(10)) returns INT(10)
    -> BEGIN
    ->         DECLARE problem CONDITION FOR 1265;
    ->         DECLARE EXIT HANDLER FOR problem
    ->                 RETURN NULL;
    ->
    ->         # do some logic, if the problem condition is met
    ->         # the function will exit, returning a NULL
    ->
    ->         RETURN 1;
    -> END
    -> //
Query OK, rows affected (0.00 sec)

mysql> DELIMITER ;
mysql>
mysql> drop function perform_logic;
Query OK, rows affected (0.00 sec)

mysql>

        
Related examples in the same category
1. Declaring a Condition and Handler
2. DECLARE CONTINUE HANDLER FOR NOT FOUND SET
3. Checking flag
4. Using while to check the condition
5. DECLARE EXIT HANDLER FOR
6. Checking Exit flag
7. Using the IF statement to verify 'CONTINUE HANDLER'
8. The example associates a handler with SQLSTATE 23000, which occurs for a duplicate-key error
9. To ignore a condition
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.