Live ORACLE

if you are Oracle Developer ,than this Blog most likely will make you happy.

About my Blog

This Blog particularized for Oracle Developers ... you will see interesting Codes for SQL , PL/SQL as well as new ideas for Developer Suite and Client Tools that will help you in your professional life ... and I hope I reach for your satisfaction.

About Me

I'm Hany Freedom , 25 years old , I live in EL-Minia City in Egypt , I'm Moderator at ArabOUG.org the best Arabic Forum for ORACLE on the Net. if you interested to know more about me .... just Click Here.

PL/SQL Block Using Multiple and Duplicate Labels

<<compute_ratio>>
<<another_label>>
DECLARE
numerator NUMBER := 22;
denominator NUMBER := 7;
the_ratio NUMBER;
BEGIN
<<inner_label>>
<<another_label>>
DECLARE
denominator NUMBER := 0;
BEGIN
-- first use the denominator value = 7 from global DECLARE
-- to compute a rough value of pi
the_ratio := numerator/compute_ratio.denominator;
DBMS_OUTPUT.PUT_LINE('Ratio = ' || the_ratio);
-- now use the local denominator value = 0 to raise an exception
-- inner_label is not needed but used for clarification
the_ratio := numerator/inner_label.denominator;
DBMS_OUTPUT.PUT_LINE('Ratio = ' || the_ratio);
-- if you use a duplicate label, you might get errors
-- or unpredictable results
the_ratio := numerator/another_label.denominator;
DBMS_OUTPUT.PUT_LINE('Ratio = ' || the_ratio);
EXCEPTION
WHEN ZERO_DIVIDE THEN
DBMS_OUTPUT.PUT_LINE('Divide-by-zero error: can''t divide '
|| numerator || ' by ' || denominator);
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Unexpected error.');
END inner_label;
END compute_ratio;
/

Share/Save/Bookmark

0 comments:

Post a Comment



Newer Posts Older Posts Home Page
 
http://www.dpriver.com/images/sqlpp-banner-2.png

Thanks for reading my Blog ... you Visitor Number :-