Solved

Working with Returned Null Values and Dates

Posted on 2013-05-29
3
451 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
3 Comments
 
LVL 76

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 73

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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…
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 video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

762 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

17 Experts available now in Live!

Get 1:1 Help Now