Oracle calculates the difference between two integers and the two integers with quotient

Source: Internet
Author: User

PL/SQL (procedural language/sql) is a procedural language.

PL/SQL is based on (block) blocks, and the entire PL/SQL block is divided into three parts

1. Declaration (Declare)

2. Execution (beginning with Begin)

3. Exception handling (starting with exception)

The syntax format for PL/SQL is as follows:

[Declare] -- Declaration section   Optional BEGIN-- Executive Section  required [EXCEPTION] -- exception handling Section optional END

PL/SQL Simple example:

--==========================================--Author:oliver QIN--date:2015-12-13--desc: Write a PL/SQL block to calculate the sum of two numbers and the quotient of the difference--==========================================Sql> SetServeroutput onSQL> Declare  2Aint:= -; 3Bint:= $; 4C Number; 5  begin  6C:=(A+b/(A-b); 7Dbms_output.put_line (c); 8Exception9       whenZero_divide Then TenDbms_output.put_line ('the divisor cannot be zero! ');  One  End;  A  /-3PL/The SQL process has completed successfully. --Change the value of B to 100 by using edit and create a case with a divisor of 0 SQL>Edit is writtenfileAfiedt.buf1  Declare  2Aint:= -; 3Bint:= -; 4C Number; 5  begin  6C:=(A+b/(A-b); 7Dbms_output.put_line (c); 8Exception9       whenZero_divide Then TenDbms_output.put_line ('the divisor cannot be zero! ');  One* End; SQL> /the divisor cannot be zero! PL/The SQL process has completed successfully.

In the entire code snippet, set Serveroutput on is used because the command is first needed in sql*plus to open the function that displays execution results on the server side.

Oracle calculates the difference between two integers and the two integers with quotient

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.