OneWhat to use the package? In a large project, there may be many modules, and each module has its own processes, functions, and so on. And these procedures, functions are put together by default (such as in PL/SQL, the process is put together by
--Demonstration of implicit cursors, automatic system declaration, auto-open, auto-use and auto-closeBegin Update emp Set sal = 1000; Dbms_output.put_line (' Number of rows affected: ' | | sql%rowcount);EndRollback/* How to use cursors:First
I. PL/SQL advanced-control structureThree conditional branching statements are available in PL/SQL if-then, if--then---else, if---then---elsif---else(1) Simple condition judgment if–thenIssue: Write a procedure that allows you to enter an employee's
Reprint: http://blog.csdn.net/jojo52013145/article/details/6758279In an actual application, in order for the PL/SQL function to return multiple rows of data, it must be done by returning a REF CURSOR or a data collection. This case of REF CURSOR is
1. Previous section ReviewThe advanced of 2.pl/sqlView of 3.oracleTrigger for 4.oracleGoal:1. master PL/SQL Advanced usage (can write paging process module, next order process module ...) )2. Common exceptions for Oracle are handled3. Oracle
Bulk gets the number of rows per child of the specified partition table!
Otherwise manual inquiry too troublesome!
---View the number of rows per child of a specified partition table
Create or replace procedure show_tabparcnt
(Partiton_tablename
21.1 CursorsThe SQL retrieval operation returns a set of rows called the result set. The rows returned by this group are rows that match the SQL statement.Result sets (result set) the results retrieved by the SQL querySome options and features of
Oracle's stored procedures and calls
Oracle Stored Procedure Syntax
Oracle's stored procedure syntax is as follows:
Create procedure stored procedure name (random)
is where you can define constants, variables, cursors, complex data types
Method One: The practice of Package and Procedure
First, create a cursor that returns a result set:
Create or Replace package PKGACCQ_TBUSERPRIsType result is REF CURSOR;End PKGACCQ_TBUSERPR;
Multiply the result knot that is thrown by using the
Declare cursor cur_login are select user_id, login, login_time from User_login; type User_id_type is table of User_login.user_id%type; type login_type is table of User_login.login%type; type Login_time_type is table of
--Build a tableCREATE TABLE Sale_report (Sale_date date not NULL,Sale_item VARCHAR (2) Not NULL,Sale_money DECIMAL (10,2) is not NULL,PRIMARY KEY (sale_date, Sale_item));--Test dataDECLAREV_begin_day DATE;V_end_day DATE;BEGINV_begin_day: = to_date ('
TYPE Type_cursor is REF cursor[RETURN Return_type];Cursor_name Type_cursor;Type type_cursor: Defines the types of variables such as I in int iIs ref CURSOR: Equivalent to a data type, but a data type that refers to a cursor. type int iThis variable
The role of Oracle's stored procedures 1. Stored procedures can make program execution more efficient and more secure, because the process is built and stored in the database, the direct write SQL needs to analyze and execute the process more
The stored procedure uses the cursor variable to return the result set. 1) log on to SQLPLUS and use the table EMP www.2cto.com [SQL] C provided by SCOTT: \ Users \ Administrator> sqlplus scott/scott 2) Compile a FUNCTION and RETURN the cursor
Writing Process: I collected and tested a lot of Oracle paging stored procedure code online. After finishing the code, I finally passed the test. Here are the test steps: 1. Run the create package command; 2. Run the create Stored Procedure command;
Use the Oracle stored procedure in C # To return the result set,
Problem:
A stored procedure defined in MSSQLServer can directly return a dataset, for example:
create procedure sp_getAllEmployeesasSELECT * FROM [NORTHWND].[dbo].[Employees]
In the
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.