How Oracle queries the role of creating execution stored procedures and cursors

Source: Internet
Author: User

Cursors are buffers of data, plsql do not allow output of set values, only single properties, cursors you can interpret as Ajax RowData

1 View the stored procedures under the current User: SELECT * from User_procedures;

2 View all users (note that there are query permissions)

SELECT * from All_procedures;

3 What is the difference between is and as in Oracle stored procedures?
There is no difference in stored procedures (PROCEDURE) and functions (function), only as cannot be used in view, only as in Cursors (CURSOR).

How to create a stored procedure.

4 Right-click New in the procedures file directory, you can enter multiple parameters (separated by commas), or you can not enter parameters as a parameterless stored procedure, if the creation is not successful, will report error red logo, edit view, will report the specific error message

5 How to execute the stored procedure.

Re-open a command line window and enter the exec stored procedure name

6 How to debug a stored procedure.

Select a stored procedure, right-click View, in the open program, double-click is the breakpoint, and then in the stored procedure right click to select Test, Debug, click on the Magnifying glass icon button is the beginning, click Triangle Review, that is to start debugging


7oracle the difference between stored procedures and functions

1. The difference between the return value, the function has 1 return values, and stored procedures are returned through parameters, can have multiple or no
2. The difference between calls, functions can be called directly in query statements, and stored procedures must be called separately.
Functions are typically used to compute and return a calculated result, and stored procedures are typically used to perform specific data operations (such as modifying, inserting database tables, or executing some DDL statements, etc.)

8oracle stored Procedure Cursor Usage questions

Create or Replace procedure D_1 is
type my_cur is REF CURSOR;
Cur my_cur;
Begin for
cur in (SELECT * from t_t)
loop
dbms_output.put_line (cur.name);
Exit when Cur%notfound;
End Loop;
Close cur;
End;
Why the execution will be in the
exit when Cur%notfound, the statement on the error, close cur, closed the cursor will also error, do not understand what is the reason for the guidance
cursor traversal data has two methods of writing
Method II:
begin
 Open Test_cursor for select ename,sal from emp where deptno=&no;
Loop
 fetch test_cursor into v_ename,v_sal;
 Exit when Test_cursor%notfound;
 Dbms_output.put_line (' Name: ' | | V_ename);
Is there any real difference from the previous method?
1, for T_name  in (select ...) loop
This is an implicit cursor, which is equivalent to a result set, and the implicit cursor is automatically turned on and off by the system.
exit when%notfound is used with the fetch, no fetch is not required.

your first stored procedure can write this:
Create or replace procedure D_1
is begin with
cur in (SELECT * from t_t)  ---This cur is an implicit cursor , no definition, direct use.
Loop
dbms_output.put_line (cur.name);
End Loop;
End;
/
2, using the standard explicit cursor
a definition cursor---Cursor  [Cursor Name] is  ;
b Open the cursor---open  [Cursor Name]; 
C  Operation Data---Fetch  [Cursor name] 
d  close cursor---Closed [Cursor name]


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.