Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Question about SQL query's behaviour

RE: Question about SQL query's behaviour

From: Nicoll, Iain (metering) <iain.nicoll_at_calanais.com>
Date: Tue, 5 Sep 2000 18:55:24 +0100
Message-Id: <10610.116230@fatcity.com>


Paul,

Iy you try 01 with the concat instead of 31 it should be ok. I believe the to_date is being done for all the dates (and therefore some are failing) before the filter from the where clause is applied. I'm not sure how else you would get round it.

Iain Nicoll

-----Original Message-----
From: Paul van Dijken [mailto:paul.vandijken_at_sema.nl] Sent: 05 September 2000 15:45
To: Multiple recipients of list ORACLE-L Subject: Question about SQL query's behaviour

Hello,

Does someone have an idea about the behaviour described below ?

I create a view in Oracle V7 as follows :

 CREATE OR REPLACE VIEW <ViewName>

     (ProdMonth,
      ProdYear)
 AS SELECT
      TO_NUMBER(TO_CHAR(DS.SelectionDate,'MM')),
      TO_NUMBER(TO_CHAR(DS.SelectionDate,'YYYY'))
 FROM
      (SELECT DISTINCT
            TO_DATE(CONCAT('31/', TO_CHAR(<DateField>,
'MM/YYYY')),'DD/MM/YYYY') SelectionDate
       FROM
           <Table>
       WHERE
           TO_NUMBER(TO_CHAR(LAST_DAY(<DateField>),'DD')) >= 31) DS;

<Table> is a table that contains a date field <DateField>.

When i execute the query "select * from <ViewName>", i have the correct result.
When i execute the query "select * from <ViewName> where ProdMonth = 8"
(or, another value), I have the following message :

ERROR:
ORA-01839: date not valid for month specified

Thanks for your answer.

-- 
Author: Paul van Dijken
  INET: paul.vandijken_at_sema.nl

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Tue Sep 05 2000 - 12:55:24 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US