Create an Oracle Stored Procedure

Source: Internet
Author: User

I am an Oracle enthusiast. The following content is my personal summary of the Oracle stored procedure, including the creation of the stored procedure and the practical application of variable assignment, the following is a description of the specific content of the article. I hope you will gain some benefits.

1. Create a stored procedure

 
 
  1. create or replace procedure test
    (var_name_1 in type,var_name_2 out type) as  

Declare variables (variable name and variable type)

 
 
  1. begin  

Execution body of the Oracle Stored Procedure

 
 
  1. end test;  

Print the input time information

 
 
  1. E.g:   
  2. create or replace procedure test(workDate in Date) is   
  3. begin   
  4. dbms_output.putline('The input date is:'
    ||to_date(workDate,'yyyy-mm-dd'));   
  5. end test;   

2. Variable assignment

Variable name: = value;

 
 
  1. E.g:   
  2. create or replace procedure test(workDate in Date) is   
  3. x number(4,2);   
  4. begin   
  5. x := 1;   
  6. end test;   

3. Judgment statement

If comparison then begin end; end if;

 
 
  1. E.g   
  2. create or replace procedure test(x in number) is   
  3. begin   
  4. if x >0 then   
  5. begin   
  6. x := 0 - x;   
  7. end;   
  8. end if;   
  9. if x = 0 then   
  10. begin   
  11. x: = 1;   
  12. end;   
  13. end if;   
  14. end test;   

The above content is a summary of the Oracle stored procedure, hoping to help you in this regard.

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.