PL/SQL - Arithmetic Operator


Advertisements

Following table shows all the arithmetic operators supported by PL/SQL. Let us assume variable A holds 10 and variable B holds 5, then −

Operator Description Example
+ Adds two operands A + 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 other A ** 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. 
plsql_operators.htm
Advertisements