Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Working with Returned Null Values and Dates

Posted on 2013-05-29
3
Medium Priority
?
457 Views
Last Modified: 2013-05-30
Ok; I have modified the file that has been delivered to me from the supplying vendor and it worked the way it should. However; I am faced with yet another small issue. When I try and select from my under lying table (New table with no data) to compare dates ; I of-course will receive a null value in my select statement. In the code snippet below, this works perfectly well if there is data in my base table APP_REGISTRAR.T_VIRTUAL_ORIENT; but if there is no data in this table because it is a new table, how can I compensate for a returned NULL value of a date datatype so that it will still bring across the initial data from my External table? I am currently running on Oracle 11g.

SELECT NETID, TO_DATE(COMP_DATE,  'YYYY-MM-DD HH24:MI:SS') "COMP_DATE"
FROM APP_REGISTRAR.T_EXTERNAL_VIRTUAL_ORIENT
WHERE TO_DATE(COMP_DATE, 'YYYY-MM-DD HH24:MI:SS') > (SELECT MAX(b.COMP_DATE) FROM APP_REGISTRAR.T_VIRTUAL_ORIENT b);
0
Comment
Question by:Seaghost
[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 Comments
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 680 total points
ID: 39205127
If the select max returns null, just use NVL to return a very early date:

WHERE TO_DATE(COMP_DATE, 'YYYY-MM-DD HH24:MI:SS') > NVL((SELECT MAX(b.COMP_DATE) FROM APP_REGISTRAR.T_VIRTUAL_ORIENT b),TO_DATE('01/01/0001','MM/DD/YYYY'));
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 680 total points
ID: 39205325
SELECT netid, TO_DATE(comp_date, 'YYYY-MM-DD HH24:MI:SS') "COMP_DATE"
  FROM app_registrar.t_external_virtual_orient
 WHERE TO_DATE(comp_date, 'YYYY-MM-DD HH24:MI:SS') >
           (SELECT MAX(comp_date)
              FROM (SELECT comp_date FROM app_registrar.t_virtual_orient
                    UNION ALL
                    SELECT TO_DATE('1', 'j') FROM DUAL));
0
 

Author Closing Comment

by:Seaghost
ID: 39205851
This information has really resolved my issues. I am really grateful for all that you do.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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 …
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
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 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…

722 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