Output query based on date - Oracle 8i

I'm writing a very simple query for output data based on date ranges, but I continue to encounter an error.

When I make this statement:

Select * from my.table
where startdate > ' 2008-01-01'

I get this error:

[ODBC] [Ora] ORA-01861: literal does not match the format string


When I format the select statement in this way:

Select * from my.table
where startdate > #2008-01-01 #.

I get this error:

[ODBC] [Ora] ORA-00932: inconsistent data types: expected DATE got the NUMBER

Currently using CF8, and what I believe is Oracle 8i. I tried these data in many other ways of formatting, but can not make it work. I know that when I query the database using access, he has no problem returns results with the date SQL formatted as # #01 / 01 / 2008

You can use the Oracle to_date() function to convert your string to a date/time object:

Select * from my.table
where startdate > to_date ('2008-01-01', ' YYYY-MM-DD "")

Otherwise, because you are using an ODBC for Oracle connection, you can try using the function CreateODBCDate() in ColdFusion:

Select * from my.table
where startdate > #CreateODBCDate("2008-01-01") #.

Or, as has already been suggested, use cfqueryparam with the proper CFSQLType, such as CF_SQL_TIMESTAMP instead of CF_SQL_INTEGER as you try to do.

You can not use a date value 'string' against a date/time column in a query Oracle, as he proceed to an implicit type conversion.

Phil

Tags: ColdFusion

Similar Questions

  • Query based on the partition of the date

    Hello

    I'm trying out only a professional successful integration in the last 24 hours of the day. If there is work that has the outcome of success and failure in the last
    24 hours for each day, I only managed the output. If there is no success for the same work, I pulled out as the last attempt at failed job.

    Here are my columns:
    current output:
     
    JOB_ID     JOBDATE               GROUP     PATH          OUTCOME          FAILED     LEVEL     ASSET
    3400908     7/27/2012 10:01:18 AM     polA     target1          Success          0     incr     clone1
    3400907     7/27/2012 10:01:09 AM     polA     target1          Failed          0     incr     clone1
    3389180     7/23/2012 10:01:14 AM     polA     target1          Failed          1     incr     clone1
    3374713     7/23/2012 10:01:03 AM     polA     target1          Success          0     incr     clone1
    3374712     7/22/2012 11:24:32 AM     polA     target1          Success          0     Full     clone1
    3367074     7/22/2012 11:24:00 AM     polA     target1          Failed          1     Full     clone1
    3167074     7/21/2012 10:01:13 AM     polA     target1          Success          0     incr     clone1
    336074     7/21/2012 10:01:08 AM     polA     target1          Success          0     incr     clone1
     
    desired output:
     
    JOB_ID     JOBDATE               GROUP     PATH          OUTCOME          FAILED     LEVEL     ASSET
    3400908     7/27/2012 10:01:18 AM     polA     target1          Success          0     incr     clone1
    3374713     7/23/2012 10:01:03 AM     polA     target1          Success          0     incr     clone1
    3374712     7/22/2012 11:24:32 AM     polA     target1          Success          0     Full     clone1
    3167074     7/21/2012 10:01:13 AM     polA     target1          Success          0     incr     clone1
    
    Here is a code I am trying to use without success:
    
    
    select *
     from
       (selectjob_id, jobdate, group, path, outcome, Failed, level, asset,
              ROW_NUMBER() OVER(PARTITION BY group, path, asset ORDER BY jobdate desc) as rn 
                   from job_table where jobdate between trunc(jobdate) and trunc(jobdate) -1 )
       where rn = 1
       order by jobdate desc;
    Thank you
    -Abe

    Hi, Abe,

    You are on the right track, using ROW_NUMBER to assign numbers and pick-up only #1 in the main query. The main thing you're missing is the PARTITION BY clause.
    You want to assign a #1 for each distinct combination of group_id, path, assets and calendar day , right?
    Then, you need to PARTITION BY group_id, path, assets and calendar day . I think you understand that when you called this thread "query based * on partition date."

    The next thing is the controlling ORDER BY clause. To know which line of each partition is assigned #1, you must order the lines of result ("Success" first, then "Failed") and after that, of jobdate (jobdate last first, which is in descending order).

    If so, that's what you want:

    WITH     got_r_num     AS
    (
         SELECT  j.*     -- or list columns wanted
         ,     ROW_NUMBER () OVER ( PARTITION BY  group_id     -- GROUP is not a good column name
                                   ,                    path
                             ,             asset
                             ,             TRUNC (jobdate)
                                   ORDER BY          CASE  outcome
                                                 WHEN  'Succcess'
                                         THEN  1
                                         ELSE  2
                                             END
                             ,             jobdate     DESC
                           )      AS r_num
         FROM    job_table  j
         WHERE     outcome     IN ('Success', 'Failed')
    --     AND     ...     -- Any other filtering, if needed
    )
    SELECT     *       -- or list all columns except r_num
    FROM     got_r_num
    WHERE     r_num     = 1
    ;
    

    If you would care to post CREATE TABLE and INSERT instructions for the sample data, and then I could test it.

    It seems that you posted several copies of this thread.  I bet that it's not your fault; This site can cause that.  Even if it's not your fault, please mark all versions duplicated this thread as "Answered" immediately and continue in this thread if necessary.

    Published by: Frank Kulash, 28 July 2012 23:47
    This site is crumbly than I thought! I saw at least 3 copies of this same thread earlier, but I'm not now.

  • Oracle query to generate date and calculate fees

    Hi, please help me to create a query to get the end result of both tables as below

     CREATE TABLE detention_charge_slot
       (slot_no NUMBER(5),
      from_days NUMBER(10),
      to_days NUMBER(10),
      charge_amount NUMBER(10,2));
    
     INSERT INTO detention_charge_slot  VALUES (1,1,4,0);
     INSERT INTO detention_charge_slot  VALUES (2,5,9,10);
     INSERT INTO detention_charge_slot  VALUES (3,10,14,20);
     INSERT INTO detention_charge_slot  VALUES (4,15,999,25);
    
       CREATE TABLE detention_invoice
       (invoice_no NUMBER(10),
      invoice_dt DATE,
      delivery_dt DATE);
    
       INSERT INTO detention_invoice VALUES(1,'10-JAN-2015','25-JAN-2015');
    

    Where expected result 1 = Invoice_no:

    Start_date End_date Days Charge_Amount
    JANUARY 10, 2015JANUARY 13, 201540
    JANUARY 14, 201518 JANUARY 2015510
    19 JANUARY 2015JANUARY 23, 2015520
    JANUARY 24, 201525 JANUARY 2015225

    If you expect more than one line in DETENTION_INVOICE, use the following query

    WITH DATES

    AS

    (SELECT DI. INVOICE_DT + FROM_DAYS - 1 START_DATE,

    LEAST (DI. INVOICE_DT + TO_DAYS - 1, DELIVERY_DT) END_DATE.

    CHARGE_AMOUNT

    OF DCS, DETENTION_INVOICE DI DETENTION_CHARGE_SLOT

    where di.invoice_no = 1)

    SELECT start_date, end_date - + 1 days START_DATE, end_date, charge_amount

    OF DATES

  • query to display data in table with several detail table

    Hi all

    I have a few cases with a table header that have more than 3 table of detail, and I have to generate the query to show all the data horizontally.

    tblHdr have column A (PK)

    tblDtl1 have column A (FK), B (PK)

    tblDtl2 have column A (FK), C (PK)

    tblDtl3 have column A (FK), D (PK)

    and I need a query to display data like this:

    AB1C3D1
    AB2C4D2
    AC5D3
    AC6

    all the Details of the table should display data based on the relationship of tblHdr (A).

    tblDtl1 have only 2 rows of data for the FK A

    tblDtl2 just for FK 4 lines of data

    tblDtl3 only 3 lines of data for the FK A

    Another example:

    AB1C1D1
    AB2C2
    A

    B3

    tblDtl1 only 3 lines of data for the FK A

    tblDtl2 have only 2 rows of data for the FK A

    tblDtl3 have only 1 rows of data for the FK A

    Please shed some light. for the record, I'll use this query in ADF, so I'll put using PLSQL in second priority.  I prefer to do it in the SQL query.

    Thank you

    Here are 3 ways. First test of data:

    drop table ta purge;
    create table ta as
    SELECT 'A' AS A FROM dual
    union all
    select 'B' from dual;
    
    drop table tb purge;
    create table tb as
    SELECT 'A' AS A, 'B1' AS B FROM dual
    UNION ALL
    SELECT 'A', 'B2' FROM dual ;
    
    drop table tc purge;
    create table tc as
    SELECT 'A' AS A, 'C1' AS C FROM dual
    UNION ALL
    SELECT 'A', 'C2' FROM dual
    UNION ALL
    SELECT 'A', 'C3' FROM dual
    UNION ALL
    SELECT 'A', 'C4' FROM dual ;
    
    drop table td purge;
    create table td as
    SELECT 'A' AS A, 'D1' AS D FROM dual
    UNION ALL
    SELECT 'A', 'D2' FROM dual
    UNION ALL
    SELECT 'A', 'D3' FROM dual;
    

    Now 3 solutions: full join, group by and pivot:

    with b as (
      select a, b,
      row_number() over(partition by a order by b) rn
      from tb
    )
    , c as (
      select a, c,
      row_number() over(partition by a order by c) rn
      from tc
    )
    , d as (
      select a, d,
      row_number() over(partition by a order by d) rn
      from td
    )
    select a, b, c, d
    from ta left join b using(a)
    full join c using(a, rn)
    full join d using(a, rn)
    order by a, rn;
    
    select a, max(b) b, max(c) c, max(d) d
    from (
      select a, null b, null c, null d, 1 rn
      from ta
      union all
      select a, b, null, null,
      row_number() over(partition by a order by b) rn
      from tb
      union all
      select a, null, c, null,
      row_number() over(partition by a order by c) rn
      from tc
      union all
      select a, null, null, d,
      row_number() over(partition by a order by d) rn
      from td
    )
    group by a, rn
    order by a, rn;
    
    select A,B,C,D from (
      select 'A' tab, a, null val, 1 rn from ta
      union all
      select 'B' tab, a, b,
      row_number() over(partition by a order by b) rn
      from tb
      union all
      select 'C' tab, a, c,
      row_number() over(partition by a order by c) rn
      from tc
      union all
      select 'D' tab, a, d,
      row_number() over(partition by a order by d) rn
      from td
    )
    pivot(max(val) for tab in('B' B, 'C' C, 'D' D))
    order by a, rn;
    
    A B C D
    A B1 C1 D1
    A B2 C2 D2
    A C3 D3
    A C4
    B

    Personally, I would prefer to view the data by using a 'join the union', in order to avoid the impression that the different detail records are related somehow.

    select ta.a, b, c, d
    from tb full join tc on 1=0
    full join td on 1=0
    right join ta on ta.a in (tb.a, tc.a, td.a);
    
    A B C D
    A B1
    A B2
    A C1
    A C2
    A C3
    A C4
    A D1
    A D2
    A D3
    B
  • output of Get-store data in the table (datagrid)

    Hello

    I'm trying to get the output of get-store data in a table (datagrid).

    Code:

    Function Get-data warehouses
    {
    $array = new System.Collections.ArrayList object
    $Script: GetDatastore = Get-Datastore
    $array. AddRange ($GetDatastore)
    $dataGrid1.DataSource = $array
    $form1.refresh)
    }

    error:

    Das Argument '0' mit dem Wert "local_datastore01" as "AddRange' nicht den Typ"System.Collections.ICollection"konvertiert werden kann:" Der Wert "local_datastore01" vom Typ VMware.VimAutomation.Cl «»»
    ient20. DatastoreImpl' nicht den Typ "System.Collections.ICollection" konvertiert werden kann. »
    -snip-
    + $array. AddRange < < < < ($GetDatastore)
    + CategoryInfo: NotSpecified: (:)) [], MethodException)
    + FullyQualifiedErrorId: MethodArgumentConversionInvalidCastArgument

    Comment:

    If I replace the query data get store-get - VM the script works great!

    What's wrong? any suggestions?

    Many thanks and greetings

    Hello

    This particular Get-Datastore call returns a single object, which cannot be converted to the ICollection. But you can do something like this:

    If ($GetDatastore-[table]) {}

    $array. AddRange ($GetDatastore)

    } else {}

    $array. Add ($GetDatastore)

    }

    It will manage both situations - when you get the data object store or table of data warehouses.

    Vitali

    Team PowerCLI

  • SQL - remove duplicate lines based on date or another column column

    Hello people, it is possible to select the last row by column for a query:

    say that my query returns:

    book_id, date, price
    ===========
    19, 10-JAN-2012, 40
    19, 16-MAY-2012, 35
    18, 10-MAY-2012, 21

    And I want him back

    book_id, date, price
    ===========
    19, 16-MAY-2012, 35
    18, 10-MAY-2012, 21

    In other words, book_id 19 appears twice at the beginning but I now come back to the last version of it (based on the date column) as well as all other lines that have no duplicates.
    Is it possible to do?
    Thank you very much

    Hello

    Here's one way:

    WITH  got_r_num     AS
    (
         SELECT     table_x.*
         ,     ROW_NUMBER () OVER ( PARTITION BY  book_id
                                   ORDER BY          dt     DESC     NULLS LAST
                                 ) AS r_num
         FROM    table_x
    )
    SELECT     *     -- or list all columns except r_num
    FROM     got_r_num
    WHERE     r_num     = 1
    ;
    

    If the combination (book_id, dt) is unique, then you can also use the LAST aggregate function.

  • Read files based on date selection

    Hello

    I have requirement such that the server there are some files for example: text20101231, text20111231, text20121231 and text (Note: exercise file does not have any suffix in its name that is text is file of the current year).

    Now in the user INTERFACE may choose 2 dates: starting from Date and to date.

    According to the date selected files should read in my code.

    For ex: If the user selects the Date from: 13/06/2011 and to this day: 31/11/2012 in the calendar then my code should read only the text20111231 and the text20121231 two files.

    I will also check if the year to date is equal to the current year, it will read the file in which it doesn't have any suffix in its name.

    Please suggest how to read the affected files based on date selection.

    Thank you.

    So I'd start with a cfdirectory to all of the directory, to get all the files.  It returns a query object.  You can then use this to do a query of queries, for example according to your date criteria.

    SELECT *.

    OF getAllFiles

    WHERE 1 = 0

    OR a name like "text #i #%".

    ...

  • Order by clause dynamic based on the Oracle

    How can I order by dynamic Clause based on the Oracle
    My query of sql function returns with SYS_REFCURSOR. and I will place the order of column as an input parameter
      create or replace
    FUNCTION TEST_SSK
    (
            p_srot  number
    )
    
    RETURN SYS_REFCURSOR
    
    AS
    C_testssk SYS_REFCURSOR;
    BEGIN
    
    OPEN C_TESTSSK FOR
    SELECT LOAN_CODE,LOAN_DATE,DUE_DATE,LOAN_AMT FROM LOAN_MASTER
    order by P_SROT;
    
    return C_testssk;
    end;
    Published by: user10736825 on December 22, 2010 11:34

    I think this would work without dynamic sql.

    You could do something like:

    ...
    OPEN C_TESTSSK FOR
    SELECT LOAN_CODE,LOAN_DATE,DUE_DATE,LOAN_AMT FROM LOAN_MASTER
    order by decode(P_SROT,1,loan_code,2,loan_date,3,due_date,4,loan_amt);
    ...
    

    P_SROT is the number of the order by column.

  • query based on a box of test input

    query based on a box of test input

    Hello
    I have this html input box and I want a query based on what I put in the input output box. What should I do now.

    Thank you


    < form id = "form1" name = "form1" method = "post" action = "" >
    < label > enter id < input type = "text" name = "textfield" / >
    < / label >
    < / make >

    I posted this as an example of what can be done, and it should work as written. However, the part 'living dangerously' is because only by using this model, as written would allow someone run a query in your database, including queries DELETE and UPDATE, without restriction. It's actually a simplified form of the one that I developed for one of my applications, as this one did a management condition and State of login, etc that I don't understand, in order to keep things simple. The one I posted is wide open , so use with caution.

    Phil

  • How can I create a query with the data control to the web service?

    I need to create a query with the order of web service data, WSDL, it is query operation, there is a message of parameter with possible query criteria and a return message contains the results. I googled but can't find anything on the query with the web service. I can't find a criterion "named" to the data control of web service as normal data control. Blog of Shay, I saw the topics on the update with the data of web service command. How can I create a query with the data control to the web service? Thank you.

    Hello

    This might help

    * 054.     Search form using control data WS ADF and complex of entry types *.

    http://www.Oracle.com/technetwork/developer-tools/ADF/learnmore/index-101235.html

  • There will be review certification essentials (OCS) for the GREAT DATA Oracle?

    Hello

    I often hear about this subject called BIG DATA much in the arena of the database

    and even at Oracle.

    Will there be a Big data Oracle Certification?

    Roger

    For now, I have no information on this subject.

    Kind regards
    Brandye Barrington

    Oracle Certification program.

  • How to disable the popup LOV (query based LOV) tabular

    Hello

    I need help. I need to make a line in a table form the read-only AND disable the Popup LOV (LOV based query). As you can see in the code below all rows with a value of "AUD" becomes read-only. Column 5 is a Popup LOV (query based LOV), and must have become read only AND disabled also. Currently, the code performs the lines = "AUD" read-only, but the user can still click on the Popup LOV this line and select a value from the list, then updates the row.

    All solutions?

    function makeRowReadOnly() {}
    {$('select[name="f06"]').each (function ()}
    var row_val = $(this) .val ();
    ROW_ID var = $(this).attr('id').substr (4);
    If (row_val is "AUD")
    {
    $("#f02_"_+_row_id).attr ("readonly", true) .addClass ('row_item_disabled');
    $("#f03_"_+_row_id).attr ("readonly", true) .addClass ('row_item_disabled');
    $("#f04_"_+_row_id).attr ("readonly", true) .addClass ('row_item_disabled');
    $("#f05_"_+_row_id).attr ("readonly", true) .addClass ('row_item_disabled');
    $("#f06_"_+_row_id).attr ("readonly", true) .addClass ('row_item_disabled');
    $("#f07_"_+_row_id).attr ("readonly", true) .addClass ('row_item_disabled');
    }
    else {}
    $("#f02_"+row_id).attr ("readonly", false) .removeClass ('row_item_disabled');
    $("#f03_"+row_id).attr ("readonly", false) .removeClass ('row_item_disabled');
    $("#f04_"+row_id).attr ("readonly", false) .removeClass ('row_item_disabled');
    $("#f05_"+row_id).attr ("readonly", false) .removeClass ('row_item_disabled');
    $("#f06_"+row_id).attr ("readonly", false) .removeClass ('row_item_disabled');
    $("#f07_"+row_id) .attr ("readonly", false).removeClass('row_item_disabled');
    }
    });
    }

    Hi dekoke_i,

    I tried this on my local instance of APEX 4.2:

    function makeRowReadOnly() {
    $('select[name="f06"]').each(function() {
    var row_val = $(this).val();
    var row_id = $(this).attr('id').substr(4);
    if (row_val == 'AUD ')
      {
        $("#f02_" + row_id).attr("readonly", true).addClass('row_item_disabled');
        $("#f03_" + row_id).attr("readonly", true).addClass('row_item_disabled');
        $("#f04_" + row_id).attr("readonly", true).addClass('row_item_disabled');
        $("#f05_" + row_id).attr("readonly", true).addClass('row_item_disabled');
        //make the popup-lov button readonly
        $('#f05_' + row_id).closest('tr').find('td span.lov a').addClass('row_item_disabled').unbind('click');
        $("#f06_" + row_id).attr("readonly", true).addClass('row_item_disabled');
        $("#f07_" + row_id).attr("readonly", true).addClass('row_item_disabled');
      }
    else {
      $("#f02_"+row_id).attr("readonly", false).removeClass('row_item_disabled');
      $("#f03_"+row_id).attr("readonly", false).removeClass('row_item_disabled');
      $("#f04_"+row_id).attr("readonly", false).removeClass('row_item_disabled');
      $("#f05_"+row_id).attr("readonly", false).removeClass('row_item_disabled');
      //enable the popup-lov button
      $("#f05_"+row_id).closest('tr').find('td span.lov a').removeClass('row_item_disabled').bind('click');
      $("#f06_"+row_id).attr("readonly", false).removeClass('row_item_disabled');
      $("#f07_"+row_id).attr("readonly",false).removeClass('row_item_disabled');
      }
    }
    

    I hope this helps!

    Kind regards

    Kiran

  • What will happen to the SQL Query based object View (EmployeesVO)

    Schema used: HR

    1. I created a view through SQL Query view object object (Table Employees - EmployeesVO).
    2. Creates an entity of the Employees (EmployeesEO) table object.
    3. In the section EmployeesVO (View object) entity objects, I chose EmployeesEO (entity object).

    What will happen to the View SQL Query object based on (EmployeesVO) will it change to VO based on entities or still to be based query VO.

    It is there because you can still base your query based Vo EO according to Vo.

    After that you base your VO on EO you can now use 'Add the attribute of the entity' to base your attribute on the atrributes of EO. Or if you skilled enough you can manually change the XML to VO

  • Create the query by combining data from DBSS_Data_Model and HostModel

    Hello

    I am trying to create a dashboard with the host server list and instances of SQL Server running on the host.

    And I am interested in creating a query by combining data model of data in SQL Server (DBSS_Data_Model) and the host (Hosts) data model, say: which connects DBSS_SQL_Server_Host and host.

    I wonder if there is way to do it?

    Thank you

    Mark

    Something like this function should work:

    def physicalHost = nullqueryStatement = server.QueryService.createStatement("(Host where name = '$hostName')")result = server.QueryService.executeStatement(queryStatement)objs=result.getTopologyObjects()
    
    if (objs != null && objs.size() > 0) {     physicalHost = objs.get(0)}return physicalHost
    

    When the input parameter "hostName" is DBSS_SQL_Server_Host.physical_host_name

    Kind regards

    Brian Wheeldon

  • Query based ViewObject does pull not all attributes, when the query has 'WITH' clause

    Hello

    12.1.2 and 12.1.3 JDeveloper

    When we try to create a custom query based ViewObject, and the query clause of "with."

    So not all the columns selected in the query are appearing as attributes of the View object in the wizard.

    This is the query. And it performs very well in Toad.

    WITH dept_count AS)

    SELECT department_id, COUNT (*) AS dept_count

    Employees

    GROUP BY department_id)

    SELECT e.first_name AS employee_name,

    DC1.dept_count AS emp_dept_count,

    m.first_name AS manager_name,

    DC2.dept_count AS mgr_dept_count

    E employees,

    dept_count dc1,

    m employees,

    dept_count dc2

    WHERE e.department_id = dc1.department_id

    AND e.manager_id = m.employee_id

    AND m.department_id = dc2.department_id;

    Only the EmployeeName attribute is extracted from the query. It does not show the rest of the attributes in the VO Wizard.

    VO.png

    (I also tried to create a VO from the EntityObject class and make it editable as false, even in this case all attributes are not displayed.)

    I was wondering if something changed in 12 c?

    It works in 11.1.1.7

    (A friend of mine just asked me this).

    Thanks for any help.

    Sameer

    Jdev dislikes the syntax

    You can rewrite as

    SELECT e.first_name AS employee_name,

    DC1.dept_count AS emp_dept_count,

    m.first_name AS manager_name,

    DC2.dept_count AS mgr_dept_count

    E employees,

    (

    SELECT department_id, COUNT (*) AS dept_count

    Employees

    GROUP BY department_id) dc1,.

    m employees,

    (

    SELECT department_id, COUNT (*) AS dept_count

    Employees

    GROUP BY department_id) dc2

    WHERE e.department_id = dc1.department_id

    AND e.manager_id = m.employee_id

    AND m.department_id = dc2.department_id

    who must work and give you the same result.

    Timo

Maybe you are looking for

  • translasion fore android

    a translate instantly massage on Skype

  • Palm E2 data loss

    Help! I loat my PALM E2 and tried to sync my desktop with a new E2 I had and she deleted the office somehow.  Is it possible to recover what was in the calendar before my mishap.  Thank you!

  • HTML5 on Playbook

    Hi guys,. I try a simple script HTML5 drag / move with ripple on the Chrome browser / emulator Playbook - that works well and when I create folder and tested PlayBook - bar not working! What could be the possible reason? I use the latest SDK BlackBer

  • My gmail does not refresh when I connect to my account.

    Original title: gmail is my sign into account but will not regenerate my gmail does not refresh when I connect to my account. I know I have mail in my Inbox because it is there on my phone.

  • We found no startup disk or disk has failed.

    Hello, in Windows 8, I get the error... We found no startup disk or disk has failed. I get the message each time that Windows 8 is an update. Thank you