Solved

null value

Posted on 2016-11-04
15
92 Views
Last Modified: 2016-12-05
hi i have this sqql select empno,hire_date from employee where hire_date is null am geting 0 rows bust when i do select * from employee i can see empty value in hire_date column
hire_date date datatype
0
Comment
Question by:chalie001
  • 3
  • 3
  • 2
  • +3
15 Comments
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 41873568
select empno, nvl(hire_date,'01-jan-2005') hiredate_with_nvl. hiredate from employee;

Can you provide the output of this in excel or screenshot ?
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 41873570
you are seeing that issue in sql*plus or toad or any other app/tool ?
0
 
LVL 24

Expert Comment

by:Pawan Kumar
ID: 41873571
Try 1

--

select empno,hire_date from employee where hire_date is null OR hire_date = ''

--

Open in new window



Try 2

--

select empno,hire_date from employee where LENGTH(hire_date) = 0

--

Open in new window


Try 3

--

select empno,hire_date from employee where hire_date = ''

--

Open in new window

0
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 250 total points
ID: 41873590
use dump(column) to see what's really in it


with employee as 
   (select 1 empno, cast('  ' as varchar2(50)) hire_date from dual
    union all select 2 empno, to_char(sysdate) hire_date from dual)
 select empno,hire_date, dump(hire_date) from employee

Open in new window

0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 41873714
@Geert
What do 2 lines "from dual"  achieve?

with employee as 
   (select 1 empno, cast('  ' as varchar2(50)) hire_date from dual
    union all 
    select 2 empno, to_char(sysdate) hire_date from dual
   )
select empno,hire_date, dump(hire_date) from employee

===============================================================
 	EMPNO	HIRE_DATE	DUMP(HIRE_DATE)
 	1			Typ=1 Len=2: 32,32
 	2	04.11.16	Typ=1 Len=8: 48,52,46,49,49,46,49,54
===============================================================

Open in new window

0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 41873758
Paul,
 Really ?

You have never been on a database where there is no employee table ?
you have never had to conjure up some sample rows to explain something using "from dual" ?

And you got to level 47 how exactly ?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:chalie001
ID: 41873795
i use is null
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 41873796
sorry... It was a serious question
I just don't follow the logic as you haven't unioned the table employee at all, you just have 2 rows from dual

did you intend to union to the table?

forgive me I was attempting to help
0
 
LVL 34

Assisted Solution

by:johnsone
johnsone earned 250 total points
ID: 41873850
Just a comment on using empty strings.  Oracle does not support empty strings, it equates them to NULL.

So, this:

hire_date = ''

will always return false.  It is impossible for anything to ever equal null.

Try them out:

select * from dual where '' = '';
select * from dual where null = '';
select * from dual where null = null;
select * from dual where '' is null;

Only the last query will return a result.  All others will return no rows.
0
 
LVL 24

Expert Comment

by:Pawan Kumar
ID: 41873857
This is working for me .. :)

with employee as 
   (select 1 empno, cast(' ' as varchar2(50)) hire_date from dual
    union all select 2 empno, to_char(sysdate) hire_date from dual)
    
select empno,hire_date
from employee
WHERE hire_date = ' '

Open in new window


Output...
----------------------------------

      EMPNO      HIRE_DATE
1      1
0
 
LVL 34

Expert Comment

by:johnsone
ID: 41873864
That has a space in it, it is not an empty string.  What was posted earlier is:

hire_date = ''

No space, so it is an empty string.
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 41874038
Paul,
i can't union the employee table, as i don't have a database here with an employee table
i don't have access to chalie001's database, i think
> you never one when a new user with a certain alias is asking question on a site and actually sitting next to you

chalie001,
how come paul get's point by using my sample, but i don't ?
0
 
LVL 48

Expert Comment

by:PortletPaul
ID: 41874152
Geert, thanks. i understand now. I  didnt befote.

chalie001
I am not comfortable having points for asking a question
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
powershell and sql server - alerting 7 77
Processing of multiple cursor 6 35
'G_F01' is not a procedure or is undefined 3 12
PL/SQL Display based on value 4 16
Creating and Managing Databases with phpMyAdmin in cPanel.
Read about achieving the basic levels of HRIS security in the workplace.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

930 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

13 Experts available now in Live!

Get 1:1 Help Now