.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ADO.NET >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

WHEN OTHERS clause Example in oracle:

Posted By:Dhivakaran       Posted Date: October 31, 2010    Points: 15    Category: ADO.NET    URL: http://www.dotnetspark.com  

WHEN OTHERS clause Example in oracle:
 

WHEN OTHERS clause Example:

CREATE OR REPLACE PROCEDURE add_new_order
    (order_id_in IN NUMBER, sales_in IN NUMBER)
IS
    no_sales EXCEPTION;

BEGIN
    IF sales_in = 0 THEN
        RAISE no_sales;

ELSE
    INSERT INTO orders (order_id, total_sales )
    VALUES ( order_id_in, sales_in );
END IF;

EXCEPTION
     WHEN DUP_VAL_ON_INDEX THEN
        raise_application_error (-20001,'You have tried to insert a duplicate order_id.');

    WHEN no_sales THEN
        raise_application_error (-20001,'You must have sales in order to submit the order.');

    WHEN OTHERS THEN
        raise_application_error (-20002,'An error has occurred inserting an order.');

END;


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend