Solved

oracle number datatype

Posted on 2011-03-02
6
437 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 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 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
Technology Partners: 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!

 
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 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

696 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