Oracle Procedure statement

Source: Internet
Author: User


Oracle Procedure statement stored PROCEDURE basic syntax create or replace Procedure <procedure_name> [(<parameters>)] IS www.2cto.com [declare section] BEGIN [<statement (s)>] [EXCEPTION <exception handler (s);] END [<procedure_name>]; <> indicates required, and [] indicates optional. Simple Example 1. Insert a record directly into the table 1) create a test table -- Test table EMPcreate table EMP (id number, tax number, -- tax insurance number -- INSURANCE) 2) insert a record using the stored PROCEDURE without the parameter proc_insert_emp. insert a record to the table EMP: create or replace procedure proc_insert_empIS www.2cto.com BEGIN insert into emp (id, tax, insurance) values (3,100,500); -- insert a record to the emp table commit; -- commit the transaction END proc_insert_emp; 3) insert a record using the stored procedure with the parameter -- stored procedure proc_insert_emp, insert a record create or replace procedure proc_insert_emp (id in number, -- input parameter, receive ID value tax in number, -- input parameter, receive tax value insurance in number -- input parameter, receive insurance value) ISBEGIN insert into emp (id, tax, insurance) values (id, tax, insurance ); -- insert a record to the emp table commit; -- commit the transaction END proc_insert_emp; call: exec proc_insert_emp (4,500,600); 4) with output parameters -- stored procedure proc_deduction, calculate Tax deduction and insurance create or replace procedure proc_deduction (emp_id in number, -- input parameter, receive ID value deduction out number -- output parameter) IS www.2cto.com BEGIN select tax + insurance into deduction from emp where id = emp_id; END proc_deduction; call: set serveroutput on; declare deduction number; begin proc_deduction (2, deduction ); dbms_output.put_line ('duction is: '| deduction); end; Author: CN. programmer. luxh

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.