Solved

oracle number datatype

Posted on 2011-03-02
6
431 Views
Last Modified: 2012-05-11
Experts... I have a database column which is of number(10,3) type. If there is no value stored in this column and  I need to check in a PL/SQL block if there is any value or not how do I do it. I cannot use NVL or NVL2 becuase if there is no value stored I need to return blank in the return variable. Only if there is a value either 0 or greater then I need to return that value in the return variable.
0
Comment
Question by:chickanna
  • 3
  • 2
6 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 200 total points
ID: 35021993
Why not use NVL2?

nvl2(column,' ',to_char(column))

the datatypes just need to match for the return values.
0
 
LVL 14

Assisted Solution

by:ajexpert
ajexpert earned 150 total points
ID: 35022029
You can use NVL and substitue -1 if its null value.  Assuming your number column will contain all +ve values

NVL(number_column, -1)

So return all values other than -1


0
 
LVL 73

Expert Comment

by:sdstuber
ID: 35022455
So, if NULL, return NULL
if 0 or greater return that value

what if less than 0?  return what?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 73

Expert Comment

by:sdstuber
ID: 35022468

for your 3 condition logic, you case

case
when yourcol is null then null
when yourcol >= 0 then yourcol
else
    --- fill something in here
end
   
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35022553
I took 'return blank' to mean a space character.

I've had some weird .Net issues where I had to return an actual space from the database and trim it in code.
0
 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 150 total points
ID: 35022583
if "blank" means a space then simply swap ' ' for the "then null" result

more interesting (and important) is the undefined condition

case
when yourcol is null then ' '
when yourcol >= 0 then yourcol
else
    --- fill something in here
end
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now