Oracle Stored Procedure syntax and compilation process explanation, oracle Stored Procedure

Source: Internet
Author: User
Tags define local

Oracle Stored Procedure syntax and compilation process explanation, oracle Stored Procedure
Syntax

CREATE [ORReplace] PROCEDURE [schema.] procedure_name [(argument [{IN | OUT | INOUT}] datatype ,... argument [{IN | OUT | INOUT}] datatype)] {IS | AS} [descriptionpart description part] in sqlstatement statement sequence [EXCEPTION Handling] END [procedureName process name];
Syntax analysis

OR REPLACE

Is an optional keyword. We recommend that you use this keyword. If the process already exists, this keyword will re-create the process, so that you do not have to delete or recreate the process.

Either the keyword IS or

They are no different. IS followed by a complete PL/SQL block, which can define local variables, but cannot start with DECLARE. Local variables are stored in the process.

Format parameters can have three modes: IN, OUT, And INOUT. If the mode is not specified for the form parameter, the default mode is IN.

IN indicates input parameters.

OUT indicates the output parameter.

HelloWorld!

Create the first Stored ProcedureHelloWorld

SQL>create or replace procedure helloworldasbegindbms_output.put_line('helloworld');end;
/

Note: you must press enter after the input is complete in the stored procedure and enter "/" in the next line to create the bucket.

When Procedure created is displayed, the stored Procedure is successfully created.

Call HelloWorld!

Run

  SQL>set serveroutput on;  SQL>exec[ute] helloworld;

The following result is displayed:

  helloworld  PL/SQL procedure successfully completed
Compilation process

Note:

No matter whether the creation is successful or not, the creation process/FUNCTION Command create procedure or create function automatically saves its source code to the database, and the compiled code can only be saved to the database after compilation.

Only the stored procedures and functions in which the compiled code is stored in the database can be called.

That is to say, if the statement for creating a stored procedure is incorrect, the source code of the stored procedure will also be put into the database, but it will be displayed as an error.

To view the error, use the USER_ERRORS data dictionary or the show errors command to query the error in the current system.

Related Article

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.