Oracle stored procedure from scratch

Source: Internet
Author: User
1. The following describes the Oracle stored procedure! 2. Focus on the preparation, debugging, and application of stored procedures, rather than the introduction of too many syntaxes! 3. As long as you understand SQL statements, you can continue

1. The following describes the Oracle stored procedure! 2. Focus on the preparation, debugging, and application of stored procedures, rather than the introduction of too many syntaxes! 3. As long as you understand SQL statements, you can continue

1. The following describes the Oracle stored procedure!

2. Focus on the preparation, debugging, and application of stored procedures, rather than the introduction of too many syntaxes!

3. As long as you know the SQL statement, you can continue reading it!

4. A stored procedure does not belong to any table, but to a user (in oracle ).

5. Now you can write the stored procedure. If you are a beginner of oralce, you should also know plsql.

Create an SQL window in plsql and write the stored procedure statements here.

5. A simple Stored Procedure

Description: create an instance;

Replace if it exists;

Procedure tells the database that you want to create or replace a stored procedure;

Test the name of the stored procedure you created;

In is fixed, indicating that the write is about to begin;

Null oracle requires at least one sentence between begin and end;

End test indicates that the stored procedure has ended. test indicates the name of the stored procedure you created above. Note that the semicolon should be written to the end;

/This can be left empty, but it is still well written. The following will tell you what it is.

6. Congratulations, you have written the stored procedure. How can this stored procedure take effect?

OK. Select the preceding five statements and press execute (F8). Okay, there is a Procedures folder in the objects window on the left, and the stored procedure test is displayed.

This indicates that the database already has your stored procedure. You can call this stored procedure.

7. Currently, the stored procedure is still attached to the database. If it is not executed (not the same as F8 execution) or not called, it is only junk.

So now you need to know how to execute the stored procedure.

First, save the preceding five statements as an SQL file, such as test. SQL.

Open the command line (run cmd) cd to the file directory where test. SQL is located;

Enter sqlplus name/password @ orcl; this is the command for entering sqlplus. If you do not understand what it means, go to google.

Well, if you come in, you should see SQL>;

Well, you can start. Input: @ test. (Commands do not include: And. Where test is the file name of test. SQL ).

Do you still remember that the last line of the preceding five rows has? If this/is not available, you should enter another/to complete the command of the execution file.

If the prompt is successful, OK, continue!

Run execute test. (Commands do not include: And. Execute is the execution of the stored procedure. Execution means that if you have an insert statement in the stored procedure, only execute is executing the insert operation, in addition, none of the f8. Test is the name of the stored procedure you created ).

If the prompt is successful, OK, and end.

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.