PL/SQL – Arithmetic Operator

  • Post author:
  • Post category:PL/SQL
  • Post comments:1 Comment

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

OperatorDescriptionExample
+Adds two operandsA + B will give 15
Subtracts second operand from the firstA – B will give 5
*Multiplies both operandsA * B will give 50
/Divides numerator by de-numeratorA / 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. 

This Post Has One Comment

Leave a Reply