473,569 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PL-SQL Tips (SINGLE ROW FUNCTIONS)

amitpatel66
2,367 Recognized Expert Top Contributor
All,

Please find below POST about Oracle SINGLE ROW FUNCTIONS which might be useful.

SINGLE ROW FUNCTION are those which are executed once for each and every row of the Query.

The different types of SINGLE ROW FUNCTIONS are:

1. NUMBER Functions
2. DATE Functions
3. CHARACTER Functions
4. CONVERSION Functions
5. GENERAL Functions

Let us categorize some of the SINGLE ROW FUNCTIONS and its usage:

NUMBER Functions:

ROUND(m,[n]) - Round the number m to n decimal places (n is optional)
Expand|Select|Wrap|Line Numbers
  1. SELECT ROUND(2.555,2) FROM dual -- returns 2.56
  2.  
Expand|Select|Wrap|Line Numbers
  1. DECLARE
  2. a NUMBER;
  3. BEGIN
  4. a:= ROUND(2.555,2);
  5. END;
  6.  
TRUNC(m,[n]) - Truncate the number m to n decimal places (n is optional)
Expand|Select|Wrap|Line Numbers
  1. SELECT TRUNC(2.555,2) FROM dual -- returns 2.55
  2.  
MOD(m,n) - Return the remainder of the number m divided by n
Expand|Select|Wrap|Line Numbers
  1. SELECT MOD(3,1) FROM dual -- returns 0
  2.  
CEIL(m) - Returns smallest integer (Whole Number) without decimal place larger than the number m
Expand|Select|Wrap|Line Numbers
  1. SELECT CEIL(1.5) FROM dual -- smallest integer larger than 1.5 is 2 so this query returns 2
  2.  
FLOOR(m) - Returns largest integer (Whole Number) without decimal place smaller than the number m (Opposite to CEIL)
Expand|Select|Wrap|Line Numbers
  1. SELECT FLOOR(1.5) FROM dual -- largest integer smaller than 1.5 is 1 so this query returns 1
  2.  
SIGN(m) - Retuns +1 if the number m >0 else Returns -1 if the number m is < 0
Expand|Select|Wrap|Line Numbers
  1. SELECT SIGN(-235) FROM dual -- returns -1
  2. SELECT SIGN(235) FROM dual -- returns 1
  3.  
POWER(m,n) - Returns multiplication of m, n times
Expand|Select|Wrap|Line Numbers
  1. SELECT POWER(2,2) FROM dual -- returns 4
  2.  
Sep 17 '07 #1
0 12285

Sign in to post your reply or Sign up for a free account.

Similar topics

4
7760
by: Hmmm... | last post by:
I am setting up a web site for a friend. Her hosting service does not support Sendmail. It is an NT server. They recommend I use Smtp. I have been using something like formmail.pl when I have been helping friends set up their web sites. Does anyone know of a perl script that works like formmail.pl, but uses Smtp. Thanks.
0
1079
by: mucha3456 | last post by:
Please send all sorts of spam to: jacek@karczmarczyk.pl jacek@karczmarczyk.pl jacek@karczmarczyk.pl jacek@karczmarczyk.pl jacek@karczmarczyk.pl
3
3617
by: D. Stimits | last post by:
I've found a number of basic references for PL/PGSQL, but am looking for something more complete. First question, is there available a *complete* reference for PL/PGSQL? I'm using PostgreSQL version 7.2.3-5.73 (for Redhat rpm packaging version), so it is version 7.2 I am concerned with information on (this is a default version, so at least on...
3
2328
by: Klaus P. Pieper | last post by:
Hi, does anybody out there have experience with the several PL's which are available for PostgreSQL? I am currently evaluating several databases (commercial as well as free & open source) for a new project and would just like to hear some feedback. PL/Java seems to be developed by a fairly small team - no updates on their website since...
22
3688
by: Christopher Murtagh | last post by:
Greetings, I'm trying to write a pl/perl function that will return multiple rows. I've looked all over the web and only found vague references as to how to do this (some said it was possible, and some said it wasn't but it was for older versions of Postgres). Basically I would *love* to be able to do something like this: SELECT some_id
2
1624
by: Chris Ochs | last post by:
I am pretty sure I know this already, but every time you run a Pl/Perl function it is just like running a perl script as far as having to load and compile the code right? My application runs under mod perl so I'm thinking that speed is not something I would gain by putting any of the code into the database server via Pl/Perl. Chris ...
1
1639
by: Eric D. Nielsen | last post by:
I'm in the process of implementing a "monitor this" type feature on a web-application. When something changes on the monitored item an email to the subscriber is generated. I'd like to do this via triggers instead of application logic. As far as I can tell pl/pgsql does not include any method for e-mailing as a function side-effect. So I...
5
3360
by: kardon33 | last post by:
Im getting these errors when i use a module, could anyone tell me what they think wrong, its the second one that i think it the problem but i don't know what it means so i cant fix it, Thank you. Premature end of script headers: test.pl, referer: http://localhost/lightmon/ Can't locate loadable object for module ArtNet in @INC (@INC...
5
7815
by: eranshuman | last post by:
Hi, I m very new to perl I m running an API which have the Buil.pl When Im compiling using perl Build.pl I was getting error : Can't locate Module/Build.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/li b .) at Build.PL line 5.
4
4723
by: peterv6 | last post by:
I'm running OS X Snow Leopard on a MacBook Pro. I've installed Mysql using Macports. MySQL works fine, but I need to install the DBI module. I've tried several ways, but I always get the following error: install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /Library/Perl/Updates/5.10.0...
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.