jollyreaper
Technical User
Crystal Reports / Server XI
Windows 2003
Topspeed ODBC
I have a query that seems to be choking on nulls. Some of the date values in the database are null. Now SQL nulls are not the same as '' so saying
where startdate<>''
wouldn't work, more's the pity. When I remove all references to date, the query runs fine. I would have thought that the where clause specifying the dates would take care of the nulls but I guess my crummy odbc driver is choking when evaluating nulls.
**uncommented query, commented one below**
SELECT "CVENDOR"."NAME", "CTASK"."STARTDATE", "CCLIENT"."ADKEY", "CCLIENT"."JOBADDR", "CTASK"."DESCRIPTION", "CDVLP"."LONGNAME", "CTASK"."ENDDATE", "CTASK"."STATUS", "CCLIENT"."SCHACTIVE"
FROM "CCLIENT" "CCLIENT", "CDVLP" "CDVLP", "CTASK" "CTASK", "CVENDOR" "CVENDOR"
WHERE ("CCLIENT"."IDCDVLP"="CDVLP"."IDCDVLP") AND ("CCLIENT"."IDCCLIENT"="CTASK"."IDCCLIENT") AND ("CTASK"."IDCVENDOR"="CVENDOR"."IDCVENDOR") AND "CDVLP"."LONGNAME"='Sail Harbour' AND "CTASK"."STATUS"<>'D' AND "CCLIENT"."SCHACTIVE"=1 AND ("CTASK"."STARTDATE">={d '2005-09-12'} AND "CTASK"."STARTDATE"<={d '2005-09-16'})
ORDER BY "CVENDOR"."NAME"
**commented query**
SELECT "CVENDOR"."NAME", "CTASK"."STARTDATE", "CCLIENT"."ADKEY", "CCLIENT"."JOBADDR", "CTASK"."DESCRIPTION", "CDVLP"."LONGNAME", "CTASK"."ENDDATE", "CTASK"."STATUS", "CCLIENT"."SCHACTIVE"
******************all of the above is just a bunch of selections, no biggie********
FROM "CCLIENT" "CCLIENT", "CDVLP" "CDVLP", "CTASK" "CTASK", "CVENDOR" "CVENDOR"
***********tables above, naturally*******************
WHERE ("CCLIENT"."IDCDVLP"="CDVLP"."IDCDVLP") AND
****linking client table to community table (i.e. the development*****
("CCLIENT"."IDCCLIENT"="CTASK"."IDCCLIENT") AND
****linking client table to task table*****
("CTASK"."IDCVENDOR"="CVENDOR"."IDCVENDOR")
****linking task to the vendor who performs the task*****
AND "CDVLP"."LONGNAME"='Sail Harbour'
***allows us to filter the development by its name rather than by its ID#****
AND "CTASK"."STATUS"<>'D'
***If the task falls within the date range but is d-for-done, do not display***
AND "CCLIENT"."SCHACTIVE"=1
***skip showing the client if the schedule is not active***
AND ("CTASK"."STARTDATE">={d '2005-09-12'} AND "CTASK"."STARTDATE"<={d '2005-09-16'})
***the timeframe the query is supposed to return for***
ORDER BY "CVENDOR"."NAME"
Here is the formula that is used to determine the timeframe.
{CTASK.STARTDATE} in currentdate-dayofweek(currentdate)+2 to currentdate-dayofweek(currentdate)+ 6
Windows 2003
Topspeed ODBC
I have a query that seems to be choking on nulls. Some of the date values in the database are null. Now SQL nulls are not the same as '' so saying
where startdate<>''
wouldn't work, more's the pity. When I remove all references to date, the query runs fine. I would have thought that the where clause specifying the dates would take care of the nulls but I guess my crummy odbc driver is choking when evaluating nulls.
**uncommented query, commented one below**
SELECT "CVENDOR"."NAME", "CTASK"."STARTDATE", "CCLIENT"."ADKEY", "CCLIENT"."JOBADDR", "CTASK"."DESCRIPTION", "CDVLP"."LONGNAME", "CTASK"."ENDDATE", "CTASK"."STATUS", "CCLIENT"."SCHACTIVE"
FROM "CCLIENT" "CCLIENT", "CDVLP" "CDVLP", "CTASK" "CTASK", "CVENDOR" "CVENDOR"
WHERE ("CCLIENT"."IDCDVLP"="CDVLP"."IDCDVLP") AND ("CCLIENT"."IDCCLIENT"="CTASK"."IDCCLIENT") AND ("CTASK"."IDCVENDOR"="CVENDOR"."IDCVENDOR") AND "CDVLP"."LONGNAME"='Sail Harbour' AND "CTASK"."STATUS"<>'D' AND "CCLIENT"."SCHACTIVE"=1 AND ("CTASK"."STARTDATE">={d '2005-09-12'} AND "CTASK"."STARTDATE"<={d '2005-09-16'})
ORDER BY "CVENDOR"."NAME"
**commented query**
SELECT "CVENDOR"."NAME", "CTASK"."STARTDATE", "CCLIENT"."ADKEY", "CCLIENT"."JOBADDR", "CTASK"."DESCRIPTION", "CDVLP"."LONGNAME", "CTASK"."ENDDATE", "CTASK"."STATUS", "CCLIENT"."SCHACTIVE"
******************all of the above is just a bunch of selections, no biggie********
FROM "CCLIENT" "CCLIENT", "CDVLP" "CDVLP", "CTASK" "CTASK", "CVENDOR" "CVENDOR"
***********tables above, naturally*******************
WHERE ("CCLIENT"."IDCDVLP"="CDVLP"."IDCDVLP") AND
****linking client table to community table (i.e. the development*****
("CCLIENT"."IDCCLIENT"="CTASK"."IDCCLIENT") AND
****linking client table to task table*****
("CTASK"."IDCVENDOR"="CVENDOR"."IDCVENDOR")
****linking task to the vendor who performs the task*****
AND "CDVLP"."LONGNAME"='Sail Harbour'
***allows us to filter the development by its name rather than by its ID#****
AND "CTASK"."STATUS"<>'D'
***If the task falls within the date range but is d-for-done, do not display***
AND "CCLIENT"."SCHACTIVE"=1
***skip showing the client if the schedule is not active***
AND ("CTASK"."STARTDATE">={d '2005-09-12'} AND "CTASK"."STARTDATE"<={d '2005-09-16'})
***the timeframe the query is supposed to return for***
ORDER BY "CVENDOR"."NAME"
Here is the formula that is used to determine the timeframe.
{CTASK.STARTDATE} in currentdate-dayofweek(currentdate)+2 to currentdate-dayofweek(currentdate)+ 6