SQL is a non procedural language and so cannot do processing of either the data used to formulate the query or process the query. For example a SQL query cannot be placed in a loop or a dynamic SQL statement cannot be constructed by just using SQL alone. One requires a procedural language extension to perform some select data processing tasks in addition to DML capabilities offered bySQL statements. PL/SQL is the procedural language extension of SQL
Exception in SQL queries can occur when a Not Found condition or when a duplicate record found occurs. A Not Found condition occurs when a select query does not find any records as per the specified criterion. For example a select statement with a where clause need not always return records. This amounts to a NOTFOUND condition and is handled in a PL/SQL block. A PL/SQL block has a declare, begin, exception and end. So when a NOTFOUND condition occurs it has to be handled as an Exception in the PL/SQL block.Similarly when a SQL statement returns many rows it causes an exception referred to as DUPLICATE ROWS. Either way, these two exceptions have to be handled in the Exception handler and appropriate processing has to be done such as a raising a form trigger failure and posting an alert message.
In some situations an undefined exception can also occur with any errors other than NOTFOUND or DUPLICATE ROWS. In such cases exceptions can be raised with reference to a specific error number and remedial action.
SQL statements that return multiple rows can also be processed using a CURSOR. The cursor has to be declared, opened and executed record by record. Records can be processed individually based on a specific condition that is expected to occur. A cursor when opened has to be closed.
A cursor has to be fetched into local variables. The advantage of cursors is that one can formulate search expressions which would have been difficult using SQL statements alone.
A typical problem requiring the use of cursors is when one cannot state explicitly using an SQL statement which record in a table has to be updated. In this case the criterion for identifying the record that has to be updated can be stated clearly using procedural language constructs. For example in a table with columns Emp Id, DOB, DOJ if one requires to construct a query to identify employees who are less than 23 years of age when they joined in service.
Using cursors one can easily select the entire record to do the above without having to specify any cumbersome criterion in the where clause and just state the processing in the cursor body using PL/SQL constructs.
By Srinivasa Gopal
Article Source: Exception Handling and Use of Cursors in PL/SQL Blocks
Article Copyright A pen that copies words that are meaningful to life, so that if words become many will be contained into a meaning of one word it is all cheers of everyone
Pages
- Denkafa Affiliate
- Omnipotent
- Taun17
- Revisi Blogging
- Article Copyright
- Privacy
- Disclaimer
- Terms Of Service
- Sitemap
- Ketentuan Layanan Penerbit Article Copyright
- Ketentuan Layanan Article Copyright
- Ketentuan layanan untuk penulis
- Room Comment Article Copyright
- Tiktok
- MineShiba
- MineWIN
- MineDoge
- MineBTTC
- MineSIA
- MineTRON
- MineEXEC
- CryptoSense
- FoucetPay
- Coinpayz
- Dunia Aneh Blog 89
- Collections Article
- Coriarti
- Pusing Blogger
India and Malaysia recently faced off in a friendly match
India and Malaysia recently faced off in a friendly match, showcasing the talent and skills of both teams. The game was highly anticipated a...
Exception Handling and Use of Cursors in PL/SQL Blocks
Label:
Article Copyright,
Canada,
Daily Devotional,
Israel,
Japan,
Malaysia,
Rusia,
Saudi Arabia,
United States
Subscribe to:
Post Comments (Atom)
-
Greater Noida West, better known as Noida Extension, is emerging as a realty hotspot for residential properties in National Capital Region ...
-
Healthcare maintenance is dependent on a CMMS (computerized maintenance management software) to meet the varieties of facilities that are re...
-
By Ronak Patel Angular was first termed in the year of 2009 through the group of developers in the way of introducing a brand new conc...
-
There have been many skeptics since the very initial introduction of wireless service about what the constant exposure to radiation can do t...
-
In today's time, there is a lot of competition among the business organization. Considering, the upward curve of mobile marketing, most ...
-
Studi mengidentifikasi hubungan potensial antara bakteri oral dan abses otak Bakteri yang diketahui menyebabkan infeksi mulut juga dapat me...
-
The Internet constantly confronts us with evidence of our past. Are we losing the chance to remake ourselves? By Nausicaa Renner In...
-
Management in marketing should be properly done to make a business successful. The relation between the consumers and sellers certainly play...
-
The security is also a concern when it comes to transport important documents and confidential papers. Here, tamper evident security envelop...
-
5 Benefits of Roller Banner Displays By Shalini Madhav Roller banner displays are known by many names. Why are there so many terms for thi...
No comments:
Post a Comment
Informations From: Article copyright