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
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)
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...
-
Greater Noida West, better known as Noida Extension, is emerging as a realty hotspot for residential properties in National Capital Region ...
-
Studi mengidentifikasi hubungan potensial antara bakteri oral dan abses otak Bakteri yang diketahui menyebabkan infeksi mulut juga dapat me...
-
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...
-
My executive coaching client, Sonya, was head of the Operations function in her organization when her boss was struck with a severe illness ...
-
Healthcare maintenance is dependent on a CMMS (computerized maintenance management software) to meet the varieties of facilities that are re...
-
Student Suicide: What Teachers Must Do and Mustn't Do By Dickson Adom Suicide rates among students are on the ascendancy globally. Sui...
-
How unreasonable are you? Odd question, isn't it? I for one try to be reasonable most of the time, though my loved ones may not agree! ...
-
I've been a musician for over 50 years! Wow, just typing that has made me flashback to a zillion hours of practice and performance. My m...
-
Electrical panel is an important component of the electricity supply system to be installed for its functioning. It divides the electrical p...
-
By Doug Setter The high school or workplace bully preys on the weaker people. By getting physically stronger, you are less of a target an...
No comments:
Post a Comment
Informations From: Article copyright