What does cursor mean?
Cursor
I. classification:
Static cursor
Explicit cursor (need to be clearly defined)
Implicit cursor (all dml statements are implicit cursors, and for loop is also implicit cursors)
Ref cursor (try not to use ref cursor. ref
Unlike SQL Server, Oracle uses Select to return the result set in the stored procedure, but returns the result set through Out parameters. It is actually using REF CURSOR
Copy codeThe Code is as follows: -- procedure returns the record set:
---------
For the default installation of the HR architecture, the console output shows the fields (separated by semicolons) for each record in the two records of the employee 101:
101;9/21/1989 12:00:00 am;10/27/1993 12:00:00 AM; ac_account;110;
101;10/28/199
Abstract OLE DB is an open specification built on the success of ODBC, which provides an open standard for accessing and manipulating different types of data. ADO is a consumer of old db that provides access to OLE DB data sources at the application
Classification of dynamic cursors:A strong type: With a return statement, you can only open query statements with the same query result as the Ruturn type.Two weak types: no Rerurn statements. Can be opened for any query statement.--Steps to use
Oracle Stored Procedure return result set
* Process return record set:
Create or replace package pkg_test
As
Type myrctype is ref cursor;
Procedure get (p_id number, p_rc out myrctype );
End pkg_test;
/
Create or replace package body
When executing a stored procedure that returns a ref cursor parameter, the Microsoft Oracle provider requires that the ref cursor be bound as an OracleParameter object of type OracleDbType. Cursor.
The DataDirect provider for Oracle does not require
PL/SQL provides six types of cursor attributes:
Cursor property
Name
Description
Example
% Found
True is returned if the record is obtained successfully. Otherwise, false is returned.
BeginUpdate t set name = 'F'
How Oracle can update newly inserted data with trigger implementation Collection1, establish the test tableCREATE TABLE TEST_TB(ID number,WLID number,PM VARCHAR2 (100),Djzt VARCHAR2 (10),SL number,PH VARCHAR2 (100));2. Set up the package and the
Procedure returns the recordset:
CREATE OR REPLACE PACKAGE pkg_test
As
TYPE Myrctype is REF CURSOR;
PROCEDURE Get (p_id number, p_rc out myrctype);
End Pkg_test;
/
CREATE OR REPLACE PACKAGE body pkg_test
As
PROCEDURE Get (p_id number, p_rc out
For the default installation of the HR architecture, the console output shows the fields (separated by semicolons) for each record in the two records of the employee 101:
101;9/21/1989 12:00:00 am;10/27/1993 12:00:00 AM; ac_account;110;
101;10/28/1
Instead of using a select in a stored procedure like SQL Server, Oracle can return a result set, which is returned by a result set of an out type parameter. is actually using ref CURSOR
Copy Code code as follows:
--procedure returns the
The cursor is performed as follows:Parse resolutionBind bindOpen opensExecute ExecuteFetch callbackClose off
1. Write your own first cursor pl/sqlDeclareCursor c_s is select * from User_tables;BeginOpen c_s; --Open cursorClose c_s;--Closing
Unlike SQL Server, Oracle uses Select to return the result set in the stored procedure, but returns the result set through Out parameters. It is actually using REF CURSORCopy codeThe Code is as follows:-- Procedure:-------------------- Declare a
Principles and usage of oracle packagesPackagePackage definition:
A package is an encapsulation package for objects such as related procedures, functions, variables, cursors, and exceptions. It consists of two parts: specification and
PL/SQL Block
Declare begin
-- SQL statement
-- SQL statement directly written (DML/TCL)
-- Indirectly write execute immediate
-- Select statement
the into clause must be included.
Select empno into eno from emp
Where e-mapreduce = 7369;
only one
Cursor and dynamic SQL, cursor dynamic SQL
Cursor type: Static cursor (the cursor is statically bound to a select statement during compilation. This cursor can only act on one query statement) and dynamic cursors (that is, we want our query
A stored procedureFirst, we set up a simple table for the test of stored procedures
The code is as follows
Copy Code
CreateTableXuesheng (ID integer, xing_ming varchar2 (), Yu_wen number, shu_xue number);Insertinto
ado| tricks ADO. NET provides a unified programming pattern and a set of common classes for any type of data access, regardless of the language in which you develop your code. Ado. NET is brand new, but as consistent as possible with ADO, it
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.