Users Online : 1514 | Tuesday 06th of January 2009   Login to CBSE Guess  New User Registration @ CBSE Guess  
CBSE - Central Board of Secondary Education, CBSE India Guess Papers, CBSE Sample Papers, Tutors In India, CBSE Schools, CBSE Books.  
CBSE CBSE Papers CBSE Schools CBSE Alumni CBSE Tutors CBSE eBooks Educational Articles Indian Education Education Forum Fun Zone Fun Zone

CBSE eBooks

CBSE Guess > eBooks > Class XII > Informatics Practices By Agnelo

Tables

Previous Index Next

PL/SQl TABLEs combine characteristics of SQL tables and C/Pascal arrays.
Like SQL tables:

  • consist of records (must have a numeric primary key)
  • can grow/shrink as elements are added/removed

Exceptions

An exception is an unusual/erroneous condition encountered during execution:

  • system error (e.g. "out of memory")
  • error caused by user program
  • warning issued by application

PL/SQL's exception handling allows these to be handled "cleanly" in a central place.

Syntax for exception handlers:
     BEGIN
          ... Statements ...
     EXCEPTION
          WHEN ExcepName1 THEN Statements1;
          WHEN ExcepName2 THEN Statements2;
          ...
     END;

If an error occurs in Statements, control is transferred to:

  • the exception handler in this block
  • the exception handler at the next enclosing block
  • ... and so on out to the system level

Example: Computing stock-market price/earnings ratio
     DECLARE
          pe_ratio NUMBER(5,1);
     BEGIN
          SELECT price/earnings INTO pe_ratio
          FROM Stocks WHERE company_name = 'Acme';
          INSERT INTO Statistics(co_name, ratio)
               VALUES ('Acme', pe_ratio);
          COMMIT;
     EXCEPTION
          WHEN ZERO_DIVIDE THEN -- divide-by-zero errors
               INSERT INTO Statistics(co_name, ratio)
                    VALUES ('Acme', 0.0);
          -- other exception handlers
     END;

Predefined Exceptions

PL/SQL provides exceptions for low-level/system errors:

INVALID_CURSOR Attempt to use non-open cursor
INVALID_NUMBER Non-numeric-looking string used in context where number needed
NO_DATA_FOUND SELECT..INTO returns no results
NOT_LOGGED_ON Attempted SQL operation without being connected to Oracle
STORAGE_ERROR PL/SQL store runs out or is corrupted
VALUE_ERROR Arithmetic conversion, truncation, size-constraint error

User-defined Exceptions

Exceptions are defined by name; used by RAISE.

Example:

     DECLARE
          outOfStock EXCEPTION;
          qtyOnHand INTEGER;
     BEGIN
          ...
           IF qtyOnHand < 1 THEN
           RAISE outOfStock;
           END IF;
            ...
     EXCEPTION
          WHEN outOfStock THEN
          -- handle the problem
     END;

User-defined exceptions are local to a block and its sub-blocks.

Previous Index Next

Informatics Practices by Agnelo
PL/SQL
Iteration
Cursors
Tables
Exception Propagation
Transactions
Procedures and Functions

Mail this page to friend    Print This Page    Add to Favorites     Make CBSEGuess Your Homepage

About Us - Success Stories - Guest Book - RSS Feeds - Education Forum - Contact Us - Help - Links - Advertise With Us - Terms of Service - Privacy Policy

Add CBSE Guess to your online bookmark site
Add http://www.cbseguess.com to your blinklist account Monitor http://www.cbseguess.com with Blogarithm Add http://www.cbseguess.com to delicious Add http://www.cbseguess.com to your digg account Add http://www.cbseguess.com to your fark account Add http://www.cbseguess.com to your furl account Add http://www.cbseguess.com to your magnolia account Meneame Add http://www.cbseguess.com to your myyahoo account Add http://www.cbseguess.com to your reddit account Add http://www.cbseguess.com to your newsvine account Add http://www.cbseguess.com to your shadows account Add http://www.cbseguess.com to your simpy account Add http://www.cbseguess.com to your spurl account Add http://www.cbseguess.com to your sync2it account

© 2003-2007, CBSE Guess.com

Website Designing, Website Development, Search Engine Promotion, Web Hosting By: DreamzSop Advertising Private Limited.