Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
PLSQL | ACOS Function
Next article icon

PLSQL | ABS Function

Last Updated : 06 Oct, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

The PLSQL ABS function is used for returning the absolute value of a number. Absolute value is used for depicting the distance of a number on the number line from 0. The direction of the number from zero is not considered since the absolute value of a number is never negative.

The ABS in PLSQL function takes as an argument any numeric data type or any non-numeric data type that can be implicitly converted to a numeric data type. The value returned by the PLSQL ABS function is of the same data type as the numeric data type of the argument.

Syntax:

ABS( number )

Parameters Used:

number – It is used to specify the number whose absolute value you want to know.

Return Value:
The ABS function in PLSQL returns a numeric value.

Supported Versions of Oracle/PLSQL:

  1. Oracle 12c
  2. Oracle 11g
  3. Oracle 10g
  4. Oracle 9i
  5. Oracle 8i

Example-1: Using a positive numeric value as an argument in the ABS function.

DECLARE      Test_Number int := 20;       BEGIN      dbms_output.put_line(ABS(Test_Number));        END; 

Output:

20 

Example-2: Using a negative numeric value as an argument in the ABS function.

DECLARE      Test_Number int := -12;       BEGIN      dbms_output.put_line(ABS(Test_Number));        END; 

Output:

12 

Example-3: Using a negative numeric value with decimal as an argument in the ABS function.

DECLARE      Test_Number decimal(7, 2) := -12.23;       BEGIN      dbms_output.put_line(ABS(Test_Number));        END;  

Output:

12.23 

Example-4: Using an expression as an argument in the ABS function.

DECLARE      Test_Number decimal(11, 2) := (-20.45 * 2);       BEGIN      dbms_output.put_line(ABS(Test_Number));        END;   

Output:

40.9 

Example-5: Using ABS function with select query.

SELECT ABS(-20.45 * 1) FROM dual; 

Output:

20.45 

Advantages:
The ABS function accepts any numeric datatype as well as any non-numeric datatype as an argument that can be implicitly converted to a numeric datatype.



Next Article
PLSQL | ACOS Function

S

Shubrodeep Banerjee
Improve
Article Tags :
  • SQL
  • SQL-PL/SQL

Similar Reads

  • PLSQL | ASIN Function
    The PLSQL ASIN function is used to return the arc sine of a number. The ASIN function only one parameter which is a number and the argument number must be in the range of -1 to 1, and the function returns a value in the range of -pi/2 to pi/2, expressed in radians. This function takes as an argument
    2 min read
  • PLSQL | ACOS Function
    The PLSQL ACOS function is used to return the arc cosine of a number. The ACOS function only one parameter which is a number and the argument number must be in the range of -1 to 1, and the function returns a value in the range of 0 to pi, expressed in radians. This function takes as an argument any
    2 min read
  • PLSQL | COS Function
    The PLSQL COS function is used to return the cosine of a numeric value. The COS function accepts one parameter which is the number whose cosine needs to be calculated. The COS function returns a value of the numeric data type. This function takes as an argument any numeric data type as well as any n
    2 min read
  • PLSQL | ATAN Function
    The PLSQL ATAN function is used to return the arc tangent of a number. The ATAN function accepts only one parameter which is a number and the range accepted for the argument number is unbounded. The ATAN function returns a value in the range of -pi/2 to pi/2, expressed in radians. This function take
    2 min read
  • PLSQL | COSH Function
    The PLSQL COSH function is used to return the hyperbolic cosine of a numeric value. The COSH function accepts one parameter which is the number whose hyperbolic cosine needs to be calculated. The COSH function returns a value of the numeric data type. This function takes as an argument any numeric d
    2 min read
  • PLSQL | ATAN2 Function
    The PLSQL ATAN2 function is used to return the arc tangent of n and m. The ATAN2 function is generally used if you want to convert cartesian coordinates to polar coordinates. The ATAN2 function accepts two parameters which are numbers and the range accepted by the argument n is unbounded. The ATAN2
    2 min read
  • PLSQL | EXP Function
    The EXP is an inbuilt function in PLSQL which is used to return a value which is e raised to the nth power. Here "e" is a mathematical constant whose value is 2.7182818 and n is the input number. Syntax: exp(number) Parameters Used: Here the parameter number is the input number which is raised to th
    2 min read
  • PLSQL | BITAND Function
    The BITAND is an inbuilt function in PLSQL which is used to returns an integer value which is calculated with AND operation of two given input decimal number. Internally these input decimal numbers get converted into binary numbers and then AND operation is performed and results are returned as outp
    2 min read
  • PLSQL | CEIL Function
    The CEIL is an inbuilt function in PLSQL which is used to return the smallest integer value which is either greater than or equal to the given input number. This input number might be in the fraction or in the whole number. Syntax: CEIL(number) Parameters Used: Here the parameter number is the input
    2 min read
  • MySQL | CAST( ) Function
    The MySQL CAST() function is used for converting a value from one datatype to another specific datatype. The CAST() function accepts two parameters which are the value to be converted and the datatype to which the value needs to be converted. The datatypes in which a given value can be converted are
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences