Solved

Working with Returned Null Values and Dates

Posted on 2013-05-29
3
455 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 170 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 170 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

623 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