SQL _ write a simple Stored Procedure for deleting employee information, SQL stored procedure

Source: Internet
Author: User

SQL _ write a simple Stored Procedure for deleting employee information, SQL stored procedure

Original Works are from the blog of "Deep Blue blog". You are welcome to reprint them. Please note the following source when reprinting them. Otherwise, you will be held legally liable for copyright.

Deep Blue blog:Http://blog.csdn.net/huangyanlong/article/details/43938953

 

Start the experiment:

(1) query raw data and use scott users for testing

SQL> select t. *, t. rowid from EMP t

(2) Compile and execute the stored procedure as follows:

Create or replace procedure P_delete_Empno (empid innumber) is

Begin

Delete from emp where emp. empno = empid;

Commit;

End P_delete_Empno;

-- Parameter description

-- P_delete_Empno indicates the name of the stored procedure

-- Empid in number indicates the parameter in the stored procedure, which is defined as the number type.

-- Begin and end are keywords for the start and end of a stored procedure.

(3) Test the Stored Procedure

SQL> select * from emp;

-- Query data. The employee information with employee number 7902 exists as follows:

Execute the following operations in the Command window:

SQL> execute p_delete_empno (7902 );

SQL> select * from emp;

-- Initiate a query again. The employee information with employee number 7902 does not exist anymore.

So far, a simple demonstration of how to delete employee information based on employee numbers has been completed.

 

Original Works are from the blog of "Deep Blue blog". You are welcome to reprint them. Please note the following source when reprinting them. Otherwise, you will be held legally liable for copyright.

Deep Blue blog:Http://blog.csdn.net/huangyanlong/article/details/43938953

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.