Oracle Stored Procedures

Source: Internet
Author: User

--Stored procedure: A set of SQL statements that complete a specific function
--If the user new ID number is not enough 18 bit error
Create or replace procedure Pro_add_teacher
(
P_tno number,
P_tname VARCHAR2,
P_tid Char,
P_sal number
)
Is
E_tid_validate exception;

Begin
If Length (P_tid)!=18--judge the ID number is not enough 18 bit error
Then--Throws an exception
Raise E_tid_validate;
End If;
Insert into teacher (tno,tname,tid,sal)
Values (p_tno,p_tname,p_tid,p_sal);
--Auto COMMIT Transaction
Commit
--handling of exceptions
exception
When E_tid_validate Then
Dbms_output.put_line (' Please enter the correct ID number! ‘);
When others then
Dbms_output.put_line (' Other anomalies have appeared! ‘);
End Pro_add_teacher;

--Call the stored procedure

Call Pro_add_teacher (2088, ' Austrian Black Donkey ', ' 123456789123568947 ', 5000.5);

Oracle Stored Procedures

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.