using SQL%BULK_ROWCOUNT and SQL%ROWCOUNT : Cursor Attributes « Cursor « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » Cursor » Cursor Attributes 
25. 14. 5. using SQL%BULK_ROWCOUNT and SQL%ROWCOUNT
SQL>
SQL>
SQL> CREATE TABLE customer_region(
  2     region_id    NUMBER(4)    PRIMARY KEY,
  3     region_name  VARCHAR2(11NOT NULL
  4  );

Table created.

SQL>
SQL>
SQL> INSERT INTO customer_region VALUES (1,'REGION1');

row created.

SQL> INSERT INTO customer_region VALUES (2,'REGION2');

row created.

SQL> INSERT INTO customer_region VALUES (3,'REGION3');

row created.

SQL> INSERT INTO customer_region VALUES (4,'REGION4');

row created.

SQL>
SQL>
SQL> DECLARE
  2    Type regionIdTableCollection IS TABLE of NUMBER INDEX BY BINARY_INTEGER;
  3    Type regionNameTableCollection IS TABLE of VARCHAR2(20)INDEX BY BINARY_INTEGER;
  4    region_ids regionIdTableCollection;
  5    region_names regionNameTableCollection;
  6    returnCode NUMBER;
  7    errorMessage VARCHAR2(1000);
  8    Procedure load_regions_bulk_bind
  9          (region_ids IN regionIdTableCollection,
 10           region_names IN regionNameTableCollection,
 11           returnCode OUT NUMBER,
 12           errorMessage OUT VARCHAR2)
 13    Is
 14    BEGIN
 15      FORALL i IN region_ids.FIRST..region_ids.LAST
 16        INSERT INTO customer_region values (region_ids(i),region_names(i));
 17      FOR i in 1..region_ids.COUNT LOOP
 18        IF SQL%BULK_ROWCOUNT(i)>THEN
 19          dbms_output.put_line(to_char(sql%bulk_rowcount(i)));
 20          NULL;
 21        END IF;
 22      END LOOP;
 23      IF SQL%ROWCOUNT =THEN
 24        DBMS_OUTPUT.PUT_LINE('No Rows inserted overall');
 25      ELSE
 26        COMMIT;
 27      END IF;
 28    EXCEPTION WHEN OTHERS THEN
 29      COMMIT;
 30      returnCode :=SQLCODE;
 31      errorMessage :=SQLERRM;
 32    END;
 33  BEGIN
 34    region_ids(1):=6;
 35    region_names(1):='region6';
 36    load_regions_bulk_bind(region_ids,region_names,returnCode,errorMessage);
 37  END;
 38  /
1

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL> drop table customer_region;

Table dropped.

SQL>
25. 14. Cursor Attributes
25. 14. 1. An example of cursorValue cursor using %ISOPEN
25. 14. 2. An example of cursor variable using %ROWCOUNT
25. 14. 3. using %ROWCOUNT as an incremental rowcount
25. 14. 4. An example to illustrate parameterized cursors and cursorValue%NOTFOUND
25. 14. 5. using SQL%BULK_ROWCOUNT and SQL%ROWCOUNT
25. 14. 6. Check sql%rowcount
25. 14. 7. While cursorVariable%found loop
25. 14. 8. Cursor not found
25. 14. 9. sql%notfound
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.