Number of data updates in Oracle

Source: Internet
Author: User

In Oracle SQL PLUS, after the update, delete, or select DML operations, the number of rows updated, deleted, or retrieved is displayed. In the JDBC operation, the returned value also indicates how many rows are affected. But how can we obtain this data in PL/SQL.

In PL/SQL, when you perform a search, you can open a cursor by yourself or not, but when you do not open the cursor, the system uses an implicit cursor in the background to achieve the same effect. Therefore, we can use some properties of the implicit cursor to obtain the execution result of the DML statement.

These attributes are obtained by using the SQL % field. Generally, three types of attributes are used: SQL % FOUND and SQL % NOTFOUND, the return values of these two types are boolean values such as true and false. The third return value is SQL % ROWCOUNT, which returns the number of data pieces in the previous operation.

The returned values of SQL % FOUND are as follows:

TRUE: INSERT

. TRUE: DELETE and UPDATE. At least one row is deleted or updated.

. TRUE: select into returns at least one row.

When SQL % FOUND is TRUE, SQL % NOTFOUND is FALSE.

In addition, I heard that sqlca. sqlerrd [2] can also return the number of update items. I didn't verify it. I don't know if I can.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.