Use 'variable command' to define variable to reference cursor : Variable « SQL PLUS Session Environment « 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 » SQL PLUS Session Environment » Variable 
29. 61. 1. Use 'variable command' to define variable to reference cursor
SQL>
SQL> set echo on
SQL>
SQL> create table t as select from all_users;

Table created.

SQL>
SQL> variable x refcursor
SQL>
SQL> begin
  2      open :x for select from t;
  3  end;
  4  /

PL/SQL procedure successfully completed.

SQL>
SQL> delete from t;

15 rows deleted.

SQL>
SQL> commit;

Commit complete.

SQL>
SQL> print x

USERNAME                          USER_ID CREATED
------------------------------ ---------- ---------
PLSQL                                  73 24-JUL-08
JAVA2S                                 36 28-JUN-08
FLOWS_020100                           35 07-FEB-06
FLOWS_FILES                            34 07-FEB-06
HR                                     33 07-FEB-06
MDSYS                                  32 07-FEB-06
ANONYMOUS                              28 07-FEB-06
XDB                                    27 07-FEB-06
CTXSYS                                 25 07-FEB-06
DBSNMP                                 23 07-FEB-06
TSMSYS                                 20 07-FEB-06

USERNAME                          USER_ID CREATED
------------------------------ ---------- ---------
DIP                                    18 07-FEB-06
OUTLN                                  11 07-FEB-06
SYSTEM                                  5 07-FEB-06
SYS                                     0 07-FEB-06

15 rows selected.

SQL>
SQL> drop table t;

Table dropped.
29. 61. Variable
29. 61. 1. Use 'variable command' to define variable to reference cursor
29. 61. 2. Bind variables can be declared in your SQL*Plus script,Preface a bind variable with a colon to reference it in a PL/SQL block
29. 61. 3. Bind variables can even be referenced by SQL queries
29. 61. 4. Define variable and print its value out
29. 61. 5. Define variable and set value
29. 61. 6. Define variable and use it in sql statement
29. 61. 7. Print variable out
29. 61. 8. Undefine variable
29. 61. 9. Check pre-defined variables
29. 61. 10. Use defined-variable in update set statement
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.