Simple oracle Stored Procedure example

Source: Internet
Author: User
Tags stored procedure example

Example of a simple oracle stored procedure -- create procedure without a parameter: drop procedure proc_testcreate or replace procedure proc_testistestvalue varchar2 (40); beginselect user_name into testvalue from user_info where user_id = 1001; values (testvalue ); end proc_test;/begin proc_test; end; -- create input parameter procedure: drop procedure success or replace procedure insert_student (user_id Number, user_name varchar2, user_pass varchar2) asbegin insert into dent stuvalues (user_id, user_name, user_pass); end insert_student; begin insert_student (1, 'aaa', 'bbb '); commit; end; drop procedure proc_test1create or replace procedure proc_test1 (invalue in Integer) astestvalue varchar2 (40); beginselect user_name into testvalue from user_info where user_id = invalue; round (testvalue); end proc_test1;/declare parameter Integer: = 1001; begin proc_test1 (parameter ); end; -- create output parameter procedure: drop procedure proc_test2create or replace procedure proc_test2 (invalue out varchar2) asbeginselect user_name into invalue from user_info where user_id = 1001; end proc_test2; /declare parameter varchar2 (20); begin proc_test2 (parameter); dbms_output.put_line (parameter); end; -- both input and output create or replace procedure proc_test3 (invalue in Integer, outvalue out varchar2) asbeginselect user_name into outvalue from user_info where user_id = invalue; end proc_test3;/Optional Integer: = 1001; parameter1 varchar2 (20); begin proc_test3 (parameter, parameter1 ); dbms_output.put_line (parameter1); end;

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.