?
Solved

oracle number datatype

Posted on 2011-03-02
6
Medium Priority
?
438 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 800 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 600 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 74

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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 74

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 77

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 74

Assisted Solution

by:sdstuber
sdstuber earned 600 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Suggested Courses

777 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