Bizare behavior date field in an Oracle database.

I have this weird data problem seeking a date field oracle.

Look at these two result sets.

Two records are missing. :

COUNTY_CDCONAMEFILE_DATETRANSMISSIONSRECORDSNO_ERROR_RECORDSERROR_RECORDSTOTAL_ERRORS
03AMADORNOVEMBER 7, 111040539699
10FRESNONOVEMBER 7, 11120420044
16KINGSNOVEMBER 7, 11312961110186194
20MADERANOVEMBER 7, 1115525351717

51SUTTERNOVEMBER 7, 1114353838

WHERE 
        r.file_date BETWEEN TO_DATE('2011-11-07 00:00:00','YYYY-MM-DD HH24:MI:SS') 
                        AND TO_DATE('2011-11-07 15:00:00','YYYY-MM-DD HH24:MI:SS') 

All records expected

COUNTY_CDCONAMEFILE_DATETRANSMISSIONSRECORDSNO_ERROR_RECORDSERROR_RECORDSTOTAL_RECORDS
03AMADORNOVEMBER 7, 111020 s39699
10FRESNONOVEMBER 7, 11120420044
16KINGSNOVEMBER 7, 11312961110186194

20MADERANOVEMBER 7, 1115525351717
50STANISLASNOVEMBER 7, 112170027165983710028
51SUTTERNOVEMBER 7, 1114353838

WHERE 
        r.file_date BETWEEN TO_DATE('2011-11-07 00:00:00','YYYY-MM-DD HH24:MI:SS') 
                        AND TO_DATE('2011-11-07 15:59:59','YYYY-MM-DD HH24:MI:SS')

Can someone tell me why recrods by the FILE_DATE field that has no portion of time looking, it's a field of data type 'DATE', would produce different results according to the time different parameters passed in the WHERE clause?  This got me really confused and I just can't understand why this behavior change which makes me leary to trust a work around solution of data random apending time just at the place where clause.

Underneath the entire SQL query of the origanal source.

SELECT
r.county_cd,
c.coname,
COUNT(unique r.file_name) AS transmissions,
count(r.use_no) AS records,
count(r.use_no) - count(e.use_no) AS no_error_records,
count(e.use_no) AS error_records, 
sum(e.errors) AS total_errors

FROM
raw_pur r INNER JOIN 
pur_lookup l
ON (r.use_no = l.use_no AND r.year = l.seq_year) LEFT OUTER JOIN
(
SELECT 
year,
use_no,
count(use_no) AS errors

FROM
errors

WHERE
NOT (error_code = 17 OR error_code = 20 OR error_code = 72 OR error_code = 52 OR
(error_code = 12 AND error_type = 'POSSIBLE') OR 
(error_code = 69 AND error_type = 'POSSIBLE') OR 
(error_code = 37 AND error_type = 'POSSIBLE') OR 
(error_code = 39 AND error_type = 'POSSIBLE'))

GROUP BY
year,
use_no
) e ON (r.year = e.year AND r.use_no = e.use_no) INNER JOIN
county c
ON (r.county_cd = c.county_cd)

WHERE 
r.file_date BETWEEN <cfqueryparam value="#form.fromDate#" cfsqltype="cf_sql_date"> 
AND <cfqueryparam value="#form.toDate#" cfsqltype="cf_sql_date">

GROUP BY
r.county_cd,
c.coname

ORDER BY
r.county_cd

Two things to consider: firstly, Yes, Oracle * always * retains part of the time in a date column, midnight if you do not specify. Secondly, cf_sql_date can give you weird results because of that, I tend to use the timestamp.

How the date has been entered in the first place? Much of the time it is put to use SYSDATE, which not only stores the date of the day, but the time, if you see that your form is another thing. Therefore, you might end up not getting results because you're doing something like this:

WHERE itemdate = February 8, 2011"

Backstage, itemdate is actually store some of the time, in order to not * not * equal this date is greater than it.

Use TRUNC (itemdate) If you want to just Oracle review date part in queries.

Tags: ColdFusion

Similar Questions

  • Import/insert data from XML in Oracle database tables?

    Hello. (I use 10.1.3.3.0 JDeveloper and Oracle 10 g)

    I was able to export the data of one of my tables in the database using a View object and .writeXML.

    Now, I want to take an xml file that is formatted just like what is spit out by the writeXML and put this info in my database table. I followed the examples online, and have tried to use .readXML as follows:

    Element = XMLDoc.getDocumentElement ();

    vo.readXML (element,-1);

    I know that it's the kind of work, because at first, I got an error message that one of the required attributes was missing. So, I added this attribute in my xml file and run my code. No errors. But, I checked my database, and new records have been added.

    Is there something I did wrong? Or is it maybe something I left out? I also noticed that there are several versions of readXML as readFromXML. Which should I use and how?

    Thank you.

    Hello

    Example of work is completely: http://kuba.zilp.pl/?id=461

    Kuba

  • Date field to update using a function table

    Hello

    Have not been able to find something like that to give me an example where I'm wrong here.

    (1) I have a table with a date field (table.created_date).

    (2) I want to recover the date field of the table when it corresponds to a field of load_week. I created a function for this.
    CREATE OR REPLACE FUNCTION ODUMGR. "" F_ODS_ET_HIST ".
    (v_load_week varchar2)
    DATE OF RETURN
    AS
    date of T_DATE;
    BEGIN
    Select trunc (max (load_date))
    in T_DATE
    of odu_course_enroll_all
    where load_week = v_load_week
    Load_week group;
    RETURN T_DATE;
    EXCEPTION
    WHILE OTHERS
    THEN RETURN ' ';
    END F_ODS_ET_HIST;
    /

    (3) I have a field in another table, in that I want to put the date that I just received. The reception table has a field of type date.

    If I try to do:

    receiving_table update
    Set receiving_table.date_field = ODUMGR. F_ODS_ET_HIST ("R08");

    When this R08 is the load_week, I get the following error:

    ORA-01847: day of the month must be between 1 and the last day of the month
    ORA-06512: AT ODUMGR. Line 15 of the F_ODS_ET_HIST
    ORA-01013: user has requested the cancellation of the current operation

    I don't know why I'd get that, given that I put a date field Oracle in an another date field in an Oracle table.

    Any ideas?

    Thank you

    VIC

    This works if you actually run the code in youe doc here :-)

    /export/home/oracle> cat t.sh
    str='Hello World'
    sqlplus -s / < ./t.sh
    Hello World
    Goodbye!
    
    PL/SQL procedure successfully completed.
    

    It takes a slash (/) on a line by itself after and before the release.

    John

  • Comparing the data set of Oracle database local to the Remote SQL Server database

    Hello

    I have a table in an Oracle database that is gradually being updated with a table in SQL server through the database link. There is a field "Date of creation" in the table in SQL server that I used to find the newly created records and shoot and insert them into the local table to the Oracle database.

    Now the question is the documents/data in the SQL server remote can be deleted as well and I see a lot of files are already deleted and I couldn't find a way to capture the information of deleted data to remove from my local table.

    I tried

    SELECT id local_table

    where there is no

    (select * (or 1))

    of remote_table@database_link

    where remote_table.id = local_table.id).

    And I tried to replace not exist with no so.

    The problem is that the query is too slow with link of database for IN/NOT EXISTS clause NO. So, I'm trying to find an effective way to capture the lines deleted in the remote to remove as a result of my local table table.

    Any help is appreciated.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit

    Thank you

    Chrystelle

    It is perhaps easier

    Select pk / * or sustitutive key * / from Oracle.tba

    less

    Select pk / * or sustitutive key * / from SQLSERVER.tab

    This returns the rows that exist in Oracle but not in SQL SERVER-> delteted lines in SQL Server.

    Another way is to create a trigger to remove in sqlserver and track in a table delete lines.

    HTH - Antonio NAVARRO

    http://SQL1.WordPress.com/

  • How to connect to an Oracle database using acrobat form field java script actions

    I have a PDF template with buttons and form fields. One requirement is that when a key is pressed, I want to connect to an Oracle database to change the data of the table inside the DB.

    I wrote "Mouse Up" event and set a Java script to run on this event. Java script I am trying to connect to the DB and Transact on the DB.

    Any ideas how to achieve this.

    Thank you.

    Assuming you are using Acrobat (or reader) XI or newer, it is no longer possible.

    There used to be a way to connect to a PDF file using a script and ADBC, a DB defined locally, but Adobe removed in favour of this option progressively and now it is completely obsolete.

    The only type of PDF files that can still do are those created using LiveCycle Designer.

  • Oracle Database vs. ofa data model

    Friends,

    I have three columns in a database table have dimensions of 2000 (varchar2)

    and existing EO and s VO based on this

    so obviously these columns of form OPS data model also 2000

    But as a change request, I need to reduce them to 1500, 1000, 1000

    I think that we cannot reduce the size in the oracle database.

    Please correct me if iam wrong.

    If this is possible please guide me

    Thank you

    Aravinda

    I said, I did the same thing,

    I think you did a sync "now, I synchrised with what I have added new columns only, now, in this respect its OK.'.»»

    It is not identical to the OT and VO again to create with the same name. If you have not done this, do.

    Also attach your research and the page controller update page. There could be something wrong in what you did.

    See you soon

    AJ

  • How can I get the text of oracle database data?

    We would like to get the text data to oracle database instead of manually in illustrator, is there a way to do it? Thank you.

    I can not extract data from databases. There may be some plug-ins for automation, somewhere, but not in native mode.

    Mylenium

  • Date of publication of Oracle 11.2.0.5 database

    Hello, you know the 11.2.0.5 Oracle database release date?

    Thank you!!

    Oracle will get out the Group of patch/upgrade of 11.2.0.5 in the future?

    N °

    What is the "end of life" / "end of support" for the 11.2.0.4 version?

    Consult the policy of life Support Oracle page 4. Extended support ended the column: Jan 2018

    This means that oracle will create paches on top of this patch set up to that time. BTW MOS Doc version database calendar current releases (Doc ID 742060.1) has the same info.

  • load data to the oracle database...

    Dear Sir

    I use to load data to oracle database .is there other methods to load bulk data to the database sql badr...

    Discover the outer table in Oracle Utilities

  • Record great shape data in the Oracle database

    Hi all

    I have a question as to how we store a large xml for example more than 10000 bytes in the oracle database. I tried to use varchar, but the length is limited to only 4000 bytes. Could someone let me know how to achieve this.

    Basically what I'm doing is in adobe livecycle workflow I will get the user entered data in the form as formData (xml) variable and I want to keep the same for any future reference. I need to use the same data to fill the form again in the future.

    Thanks in advance.

    Shekhar,

    I had handy MySQL, so I did it using that and attached here is a sample. For Oracle, this is mission for you as well as recovery.

    -Wasil

  • How do I know the date when an oracle database is improved

    Hello

    I would like to know the date when an oracle database is upgraded (for example 10.2.0.4 to 11.2.0.3).

    Can you help me find these details.

    Thank you

    Delphine

    To be more precise, you can query

    Select to_char (ACTION_TIME,'MON-DD-YYYY ""), the SUBMISSIONS in ACTION, ID, VERSION, BUNDLE_SERIES, of DBA_REGISTRY_HISTORY where ACTION = 'upgrade ';

    Example:

    SQL > select to_char (ACTION_TIME,'MON-DD-YYYY ""), the SUBMISSIONS in ACTION, ID, VERSION, BUNDLE_SERIES, of DBA_REGISTRY_HISTORY where action = 'upgrade ';

    TO_CHAR (BILL ACTION VERSION ID BUNDLE_SERIES COMMENTS

    ----------- ------------------------------ ------------ ---------- ------------------------------ ----------------------------------------

    6 March, 2009 UPDATED 10.2.0.4.0 improved 10.2.0.3.0

  • How to define JDBC Data Sources in Oracle MapViewer for Oracle database 12 c Release 1 (12.1.0.1)

    How to define JDBC Data Sources in Oracle MapViewer for Oracle database Release 1 (12.1.0.1) 12 c?

    Here is my setup in the conf\mapViewerConfig.xml:


    < name map_data_source = "mvdemo12".

    jdbc_host = "127.0.0.1".

    jdbc_sid = "orcl12c1".

    jdbc_port = '1522 '.

    jdbc_user = "mvdemo".

    jdbc_password = "7OVl2rJ + hOYxG5T3vKJQb + hW4NPgy9EN.

    jdbc_mode = 'thin '.

    number_of_mappers = '3 '.

    allow_jdbc_theme_based_foi = 'true '.

    Editable = "true" / >

    <!--  ****  -->

    But it does not work.

    After use "sqlplus mvdemo / [email protected]:1522 / pdborcl", it connected to the Oracle 12 c database.

    Anyone know it?

    Thank you

    11.1.1.7.1 use the jdbc_sid syntax, i.e.

    as described in the README file, mypdb1.foo.com

    -Sources of native data (no container) MapViewer can now use the service name of database instead of SID. To provide a db service name, you will use the same attribute of jdbc_sid, but specify the name of the service with double slashes in front, as follows:

    jdbc_host = "foo.com"

    jdbc_sid="//mypdb1.foo.com".

    jdbc_port = '1522 '.

    ... ...

    />

    Use a container_ds to the 11.1.1.7.0.

    that is, instead of using

    jdbc_host = "mydbinstance".

    jdbc_sid = "pdborcl12c".

    jdbc_port = '1522 '.

    jdbc_user = "mytestuser".

    jdbc_password = "m2E7T48U3LfRjKwR0YFETQcjNb4gCMLG8/X0KWjO00Q ="

    jdbc_mode = 'thin '.

    number_of_mappers = "6".

    allow_jdbc_theme_based_foi = "false".

    Editable = "false".

    />

    use

    container_ds = "jdbc/db12c.

    number_of_mappers = "6".

    allow_jdbc_theme_based_foi = "false".

    Editable = "false".

    />

    In my case the Glassfish 3.1.2.2 JDBC connection pool definition has been

    Property

    URL jdbc:oracle:thin:@mydbinstance:1522/pdborcl12c.rest_of.service.name

    Uncheck the wrap JDBC objects in advanced Panel, that is, the page properties change JDBC connection advanced pool.

    Add a resource to that newly created JDBC pool

    Use in mapviewerconfig.xml as above

  • Retrieve Oracle database data and store it in a CSV file format

    Hello.

    I try to export a table in an Oracle database to CSV file with any Oracle adapter format and store it in a system of HDFS.

    How could I do?

    Thanks in advance!

    Xavi says:
    HI Charles. If I could use... Oracle Data Integrator Application adapted for Hadoop? For this purpose?

    Thanks in advance

    Perhaps. I must admit I'm not familiar enough with ODI to see if this is the extent of its means.

    You might see if there is a forum for ODI and ask your question to that.

    Charles Lamb

  • Loading data to SQL server for the Oracle database

    I want to create a table in oracle db table in sql server. Table is huge that he has obtained the documents 97,456,789.
    I created the link (HS) db in the oracle database that points to the sql server. I choose this oracle db on the link table.

    Select * from 'dbo '. "T1@dblink;

    I shot below to create the table.
    create table t2 nologging parallel (degree = 3) as select * from 'dbo '. "T1@dblink;
    and its taking a long time... but its operation...

    is there any other method to do this and and fill the table in oracle db faster.

    Please notify. Thank you.

    vhiware wrote:
    create table t2 nologging parallel (degree = 3) as select * from 'dbo '. "T1@dblink;
    and its taking a long time... but its operation...

    I doubt that parallel processing will be used because it is unique to Oracle (using rowid varies in general) and not SQL-Server.

    is there any other method to do this and and fill the table in oracle db faster.

    Part of the performance overhead is to pull that data from SQL Server to Oracle in the whole of the liaison network between them. This can be accelerated by compressing the data first - and who then transfer them over the network.

    For example: using + bcp + to export the data in the SQL Server box to a CSV file, compress/zip file, scp/sftp file Oracle and then to unzip there. In parallel and direct treatment of load can now be done using SQL * Loader to load the CSV file into Oracle.

    If it is a basic Linux/Unix system, the process of decompression/unzip can be run in parallel with the SQL * process Loader by creating a pipe between the two – where the decompression process writes data uncompressed in the pipe and SQL * Loader reads and loads the data that is available through the pipe.

    Otherwise you are PQ own transformation. Assume that the data is date varies. You can create a procedure on Oracle that looks like this:
    {code}
    create or replace procedure as copyday (day) is
    Start
    Insert / * + append * / into local_tab select * from remote_tab@remotedb where col_day = day;
    -Add logging info, validation, etc.
    end;
    {code}

    You can now start 10 or more of these different days and run it in the background using DBMS_JOB.

  • Helps the model clause. Date field in the Dimension

    Hello, all.

    I'm having a problem with the clause type in my query. In my view, it may be a misunderstanding on my part, but I can't find any documentation that is opposed to the use of the date fields in the dimensions of my model.

    Given these data;
    LOGDATE               SHIFTNAME  BUILDING  UNIT  DOORNUMBER  INOUT    EVENTCOUNT
    2012-02-01 06:00:00      A        1800      R      Door 4     Out         14
    2012-02-01 06:00:00      A        1800      R      Door 4     In          15
    2012-02-01 18:00:00      D        1800      R      Door 4     Out         17
    2012-02-01 18:00:00      D        1800      R      Door 4     In          19
    2012-02-02 06:00:00      A        1800      R      Door 4     Out         14
    2012-02-02 06:00:00      A        1800      R      Door 4     In          14
    ...
    I write my SQL like this:
    SELECT logdate, shiftname, building, unit, doornumber, inout, eventcount
      FROM door_events
     WHERE building='1800' AND unit='R' AND doornumber=4
     MODEL DIMENSION BY (logdate, shiftname, building, unit, doornumber, inout)
           MEASURES (eventcount)
          RULES ()
    And I get the expected result. (The same table as above) But when I try to add rows using rules, I get no new line until the LOGDATE field is a date. For example, by using this code, I expect to get a new line, with a 100 EVENTCOUNT (and other fields as written) but I stiill get the same set of data (no line is added)
    SELECT logdate, shiftname, building, unit, doornumber, inout, eventcount
      FROM door_events
     WHERE building='1800' AND unit='R' AND doornumber=4
     MODEL DIMENSION BY (logdate, shiftname, building, unit, doornumber, inout)
           MEASURES (eventcount)
           RULES (eventcount[SYSDATE,'X','1800','R',4,'In'=100)
    However, when I turn the LOGDATE field in a CHAR data type (and make the SYSDATE a TANK in the same way) with the code below, all of a sudden I get the line I was expecting!
    SELECT TO_CHAR(logdate,'YYYY-MM-DD HH24:MI:SS') logdate, shiftname, building, unit, doornumber, inout, eventcount
      FROM door_events
     WHERE building='1800' AND unit='R' AND doornumber=4
     MODEL DIMENSION BY (logdate, shiftname, building, unit, doornumber, inout)
           MEASURES (eventcount)
           RULES (eventcount[TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS'),'X','1800','R',4,'In'=100)
    
    
    LOGDATE               SHIFTNAME  BUILDING  UNIT  DOORNUMBER  INOUT    EVENTCOUNT
    2012-02-01 06:00:00      A        1800      R      Door 4     Out         14
    2012-02-01 06:00:00      A        1800      R      Door 4     In          15
    2012-02-01 18:00:00      D        1800      R      Door 4     Out         17
    2012-02-01 18:00:00      D        1800      R      Door 4     In          19
    2012-02-02 06:00:00      A        1800      R      Door 4     Out         14
    2012-02-02 06:00:00      A        1800      R      Door 4     In          14
    ...
    2012-02-07 15:18:33      X        1800      R      Door 4     In          100
    Can someone explain this behavior? I intend to do some calculations on the LOGDATE dimension and I would like to keep it as a date. Thanks in advance for any help!

    I do not get the same result. When I use SYSDATE, I don't get the extra line. When I use TO_CHAR (SYDATE...) as you say, I still don't get the extra line.

    However, when I use a constant date, such as TO_DATE (' 2012/02/07 02:00 ',' YYYY-MM-DD HH24:MI:SS'), then I get the extra line.

    This behavior is described in http://docs.oracle.com/cd/E11882_01/server.112/e25554/sqlmodel.htm#BEIGGGFJ

    «Using UPSERT creates a new cell corresponding to that referenced on the left-hand side of the rule when the cell is absent, and the cell reference contains only positional references * qualified constants *.»

    Best regards, stew Ashton

    P.S. "Oracle Database 11g Enterprise Edition Release 11.2.0.2.0.

    Published by: stew Ashton on 7 February 2012 23:03

Maybe you are looking for

  • How can I install adobe Flash Player 15.0.0.246

    I keep getting errors or the blocking of Mozilla Firefox. Should I go to I.e. assistance?

  • ePrint does not-C310a

    Yesterday bought a C310a, everthing seemed to work perfectly (print apps included) outside of the ePrint, use the update software option the firmware update (which reset the e-mail ID) but still no ePrint. The problem is that, although Web Services i

  • L755-18Z - poor quality satellite keyboard

    Hello Just to start this thread to share my frustration about the keyboard on my Satellite L755-18Z. It is absolutely worst keyboard that I've tried. Type something's been pain in the a$ $ from the moment where I had this laptop 2 years ago. The keys

  • Saving settings of the camera when NEITHER-MAX is closed

    I'm currently building an application with a G504B of Manta, which is compatible NI_IMAQdx. I have problems with the UserSetDefaultSelector attribute. This attribute is supposed to define the power of the default settings. Here is my sequence of step

  • Digital background color works do not when you use the reference

    Hello I am trying to use a reference to change the background color of a digital indicator in a Subvi.  The sub - VI strives to change a digital indicator, but when I use a reference to another (reference Numeric.vi) VI, instead of doing all the back