Solved

Working with Returned Null Values and Dates

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle mutateing errors 3 26
UTL_FILE invalid file operation 5 58
populate value based on what is selected in lov 2 66
Oracle Date 6 41
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

734 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