PL/SQL - Arithmetic Operators

Advertisements


Following table shows all the arithmetic operators supported by PL/SQL. Assume variable A holds 10 and variable B holds 5, then:

OperatorDescriptionExample
+Adds two operandsA + B will give 15
-Subtracts second operand from the first A - B will give 5
*Multiplies both operands A * B will give 50
/Divides numerator by de-numerator A / B will give 2
**Exponentiation operator, raises one operand to the power of otherA ** B will give 100000

Example:

BEGIN 
   dbms_output.put_line( 10 + 5);
   dbms_output.put_line( 10 - 5);
   dbms_output.put_line( 10 * 5);
   dbms_output.put_line( 10 / 5);
   dbms_output.put_line( 10 ** 5);
END;
/

When the above code is executed at SQL prompt, it produces the following result:

15
5
50
2
100000

PL/SQL procedure successfully completed.


Advertisements
Advertisements