Oracle Date in SQL Statement.

Hello,
    We are having performance issues with some reports using conditions on date fields in the Record Selection Formula. Our application does not use the time portion of the date fields very often. When Crystal Reports builds the SQL statement to Oracle it uses a range condition to include all the possible time values. This practice makes a big difference compared to a direct condition
     Example:   SELECT "TABLE_A"."ID"
                       FROM   "TABLE_A"
                       WHERE  ("TABLE_A"."DT">= TO_DATE('2011-03-31 00:00:00','YYYY-MM-DD HH24:MI:SS') AND
                                      "TABLE_A"."DT"< TO_DATE('2011-04-01 00:00:00','YYYY-MM-DD HH24:MI:SS'))
     Is there a way to tell Crystal not to perform range validation on dates?
     We would like to have a SQL Statment that looks like:
                       SELECT "TABLE_A"."ID"
                       FROM   "TABLE_A"
                       WHERE  ("TABLE_A"."DT" = TO_DATE('2011-03-31'))
    We are on Oracle 11 with Crystal Report for VS2010 Sp1.
Thank you.
Charles

Have a look at the kbase below. I think this is a throwback to the fact that we can't handle the milliseconds in the DateTime. So, in order to ensure we get the correct data we search on a range plus one second of what you asked for.
[1217417 - SQL query shows '&lt;' for a DateTime field filter although '&lt;=' was selected |http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313337333433313337%7D.do]

Similar Messages

  • Compare date in SQL statement

    yup.. how can i compare date in SQL statement??
    pls give me a completed example.

    I'd think this is a formatting problem. Why not try:
    PreparedStatement ps = myConnection.prepareStatement(
    "SELECT * FROM Receipt WHERE to_date(Date) > ? ");
    ps.setDate(1,TodayDate);
    ResultSet rs = ps.executeQuery();
    HTH,
    Ken

  • How to load oracle data into SQL SERVER 2000?

    how to load oracle data into SQL SERVER 2000.
    IS THERE ANY UTILITY AVAILABLE?

    Not a concern for an Oracle forum.
    Als no need for SHOUTING.
    Conventional solutions are
    - dump the data to a csv file and load it in Mickeysoft SQL server
    - use Oracle Heterogeneous services
    - use Mickeysoft DTS
    Whatever you prefer.
    Sybrand Bakker
    Senior Oracle DBA

  • How to parsing xml data in sql statement??

    Hi friends, I have a table which contain column as clob ,stores in xml format, for example my column contain xml data like this
    <Employees xmlns="http://TargetNamespace.com/read_emp">
       <C1>106</C1>
       <C2>Harish</C2>
       <C3>1998-05-12</C3>
       <C4>HR</C4>
       <C5>1600</C5>
       <C6>10</C6>
    </Employees>
      Then how to extract the data in above xml column data using SQL statement...

    Duplicate post
    How to parsing xml data in sql statement??

  • Migrating Oracle data to SQL

    I am receiving the following error message when attempting to migrate Oracle data to SQL Server 2008. The migration tool being used is SSIS 2008 wizard. Only a few table objects are impacted by this migration.
    Thank you in advance for your assistance.
    ERROR:
    Data Flow Task: OLE DB Destination [1]: Cannot retrieve the column code page info from the OLE DB provider. If the component supports the "DefaultCodePage" property, the code page from that property will be used. Change the value of the property if the current string code page values are incorrect. If the component does not support the property, the code page from the component's locale ID will be used.

    Sorry, but we can't help you. This is a forum for Migrations from Foreign Databases (like SQL Server) to Oracle, using the Oracle SQL Developer Migration Workbench.
    SSIS is a Microsoft product, and your migration is going the other direction, so you need to ask in Microsoft forums.
    I just googled for "Cannot retrieve the column code page info from the OLE DB provider", and there were several hits in MSDN.
    Regards
    Wolfgang

  • Manipulate Data in SQL Statement

    Hello there!
    I want to manipulate Data in a SQL Statement. For instance:
    SELECT
       name
       age
    FROM pers INTO CORROSPONDING FIELDS OF it_ppl WHERE company = '01'.
    The outcome would be something like
    Hans   25
    Sam    23
    Marie  28
    Julia  23
    So what if I want to add an column behind the selected data, where the data output should not be variable from the database but a konstant, fix value?
    I tried it like that:
    SELECT
       name
       age
       'Fix value' AS value
    FROM pers INTO CORROSPONDING FIELDS OF it_ppl WHERE company = '01'.
    Outcome should be like
    Hans   25  Fix value
    Sam    23  Fix value
    Marie  28  Fix value
    Julia  23  Fix value
    The big question is: a) Is this possible with Open SQL and if so b) how?!
    Thanks in advance,
    kind regards,
    Christof!

    Its possible through Native SQL. I have done some small modification to the standard SAP help program . Please check it.
    types: BEGIN OF ty,
            connid   TYPE spfli-connid,
            cityfrom TYPE spfli-cityfrom,
            cityto   TYPE spfli-cityto,
            text type char03,  "<---
          END OF ty.
    DATA c1 TYPE spfli-carrid VALUE 'LH'.
    data:it type table of ty,wa type ty.
    EXEC SQL PERFORMING loop_output.
      SELECT connid, cityfrom, cityto, 'abc' as text  "<---
      INTO   :wa
      FROM   spfli
      WHERE  carrid = :c1
    ENDEXEC.
    break-point. "Check the values in IT here
    FORM loop_output.
      append wa to it. "<---
    ENDFORM.

  • Oracle 7 - Maximum SQL statement length

    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch44.htm#288033
    Like above, maximum SQL Statement Length is clearly defined on the "Reference" document of Oracle 8, 9, and 10.
    But I could not find it for Oracle 7.
    Can someone help me?

    This info is available in the Oracle 7 Server Reference. It can be found via http://otn.oracle.com/documentation. Look at the "Previously Released Oracle Documentation" to access it. It's a pdf. Here's a direct link: http://download-uk.oracle.com/docs/pdf/A32589_1.pdf. The details can be found in chapter 5.
    It comes down to this: 64k.
    MHE

  • Oracle Spatial operator SQL statement help

    I have a 3D elevation point feature class (elev) and a polygon feature class (Building) loaded in Oracle Spatial. I am trying to update the "HEIGHT" attribute of the "Building" Feature class using the average elevation of "elev" feature class. Here below is the SQL statement I used, which generated the same value for all buildings. The avg(elevation) returns the average elevation of all points within all building polygons, not all points within ONE polygon.
    Please help and thanks.
    update building
    set height = (select avg(elevation)
    from elev e, building b
    where sdo_anyinteract(e.shape, b.shape) = 'TRUE');

    Hi,
    try this
    update building b
    set height = (select avg(elevation)
    from elev e where sdo_anyinteract(e.shape, b.shape) = 'TRUE');
    Udo

  • Oracle to T-SQL statement

    Short version of a long story. I am trying to use T-SQL to write a number of create statements to be used in an Oracle database. The Oracle statement that I would use to get the output I am looking for is:
    select 'comment on column someschema.'||table_name||'.'||column_name||' is '''||comments||''';'
    from dba_col_comments
    where comments is not null
    and owner ='SOMESCHEMA'
    order by table_name;
    However, my feeble attempts (based on numerous web searches, I am an Oracle DBA, not SQL Server) have produced this so far:
    SELECT 'comment on column someschema.'+B.TABLE_NAME+'.',A.objname+' '''+cast(A.value as varchar)+''';' as value
    FROM fn_listextendedproperty('MS_DESCRIPTION','schema','dbo','table','SOMETABLE','column',default)
    as A, INFORMATION_SCHEMA.TABLES as B
    where value is not null
    GO
    This does not produce the output I need. This requires that I explicitly provide the table name for each table. I want this to be pulled dynamically as in the Oracle code. It also complains when I try to concatenate the '.' and A.objname with a +.
    It only runs when I put that into a separate column using the comma.
    I appreciate any suggestions anyone can provide.

    kalffiend,
    check if this works :
    --check this
    SELECT 'comment on column '+ sch.name+'.'+t.name+'.'+c.name+' is"'+ cast(value as varchar)+'";'
    FROM sys.extended_properties AS ep
    INNER JOIN sys.objects AS t ON ep.major_id = t.object_id
    INNER JOIN sys.schemas sch ON sch.schema_id=t.schema_id
    INNER JOIN sys.columns AS c ON ep.major_id = c.object_id
    AND ep.minor_id = c.column_id
    WHERE class = 1
    (couldn't test sorry)
    check this as well fr reference:
    http://technet.microsoft.com/en-us/library/ms186989(v=sql.105).aspx
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Passing date to another form and use the date in sql statement

    hello! to all programmers
    i have some small problem that need some help.
    i want to use date value parameter from the first page in the second page sql statement but i get invalid cursor state error so if anyone can solve this problem or give me a better solution to do this process.
    thanks in advance
    p/s
    EBDATE is define as date data type in my database.
    this is part of my jsp code...
    <---------------------------------------------------------------------->
    SimpleDateFormat sdfInput = new SimpleDateFormat( "yyyy-MM-dd" );
    SimpleDateFormat sdfOutput = new SimpleDateFormat ( "dd/MM/yyyy" );
    String date= request.getParameter("date");
    Date date1 = sdfInput.parse(date);
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:wtmis_db","","");
    Statement stmt=con.createStatement();
    ResultSet set=stmt.executeQuery("select * from ELECTRICBIL where EBDATE="+sdfOutput.format(date1));
    if (set!=null)
    set.next();
         Date bildate =set.getDate ("EBDATE");
         Date sdate =set.getDate ("EBSTARTDATE");
         Date edate =set.getDate ("EBENDDATE");
         int kw =set.getInt ("EBKILOWATT");
         int maxdemand =set.getInt ("EBMAXIMUMDEMAND");
         int days =set.getInt ("EBDAYS");     
    <---------------------------------------------------------------------->

    Try this
    <%
    while(set.next())
    Date bildate =set.getDate ("EBDATE");
    Date sdate =set.getDate ("EBSTARTDATE");
    Date edate =set.getDate ("EBENDDATE");
    int kw =set.getInt ("EBKILOWATT");
    int maxdemand =set.getInt ("EBMAXIMUMDEMAND");
    int days =set.getInt ("EBDAYS");
    %>
    <tr>
    <td width="211"><div align="left"><b>Bill Date :</b></div></td>
    <td width="573"><%=sdfOutput.format(date1)%></td>
    </tr>
    <tr>
    <td width="211"><div align="left"><b>Bill From :</b></div></td>
    <td width="573"> <input type="text" name="textfield" value="<%=sdate%>"></td>
    </tr>
    <tr>
    <td width="211"><div align="left"><b>Bill To :</b></div></td>
    <td width="573"> <input type="text" name="textfield2" value="<%=edate%>"></td>
    </tr>
    <tr>
    <td width="211"><div align="left"><b><b>kiloWatt Use (Rm)</b>: </b></div></td>
    <td width="573"> <input type="text" name="textfield2" value="<%=kw%>"></td>
    </tr>
    <tr>
    <td width="211"><div align="left"><b>Max Demand kiloWatt (Rm):</b></div></td>
    <td width="573"> <input type="text" name="textfield2" value="<%=maxdemand%>"></td>
    </tr>
    <tr>
    <td width="211"><div align="left"><b>Days In Billing :</b></div></td>
    <td width="573"> <input type="text" name="textfield2" value="<%=days%>"></td>
    </tr>
    <%
    %>
    i hope. Now u wouldn't get any error message...but...u wouldn't get results as well...Check ur date format with access date format....
    Revert back

  • Date in SQL Statement

    Hi,
    In oracle, there is a bulit in command, sysdate to retrieve the current system date. Is there any command to retrieve current system month and year?
    Tina

    Is, TO_CHAR(SYSDATE,'YYYY-MM'), what you want ?
    /Uffe

  • Append a string while fetching data Through Sql Statement

    Hi i have a table which having a one field contains information of some delted files.
    when i write a sql query to fetch the information its giving out put like ..
    SELECT DISTINCT filedname  FROM TB_JOBCOMP_DBS40
    Assinid
    complte_date
    pr_date
    but i need a out put like
    Assinid -------------------->deleted
    complte_date -------------------->deleted
    pr_date -------------------->deleted
    is there any way to write sql to fetch this information

    Are you looking for concatenation ?
    SQL> select concat(ename,'----- Names Of employee') from emp
      2  WHERE rownum<3
      3  ;
    CONCAT(ENAME,'-----NAMESOFEMPLOYEE')
    SMITH----- Names Of employee
    ALLEN----- Names Of employee
    SQL> select ename||'----- Names Of employee' from emp
      2  WHERE rownum<3;
    ENAME||'-----NAMESOFEMPLOYEE'
    SMITH----- Names Of employee
    ALLEN----- Names Of employee

  • Executing SQL statements in container managed transactions

    I have a problem when using TopLink 9.0.3 with WebSphere 4, Oracle 9i and J2EE container managed transactions.
    The data changing SQL statements are executed at the end of the (container managed) transaction, not at the time of the calls to UnitOfWork.registerNewObjekt(),
    UnitOfWork.validate...() or UnitOfWork.commit...().
    UnitOfWork(2035008996)--validate object space.
    UnitOfWork(2035008996)--validate cache.
    UnitOfWork(2035008996)--JTS#beforeCompletion()
    UnitOfWork(2035008996)--Connection(398132708)--INSERT INTO SVM_PERSONEN (FAX, NAME, ID, [...]) VALUES ([...])
    UnitOfWork(2035008996)--JTS#afterCompletion(org.omg.CosTransactions.Status._StatusRolledBack=4)
    UnitOfWork(2035008996)--release unit of work
    But the end of the transaction is out of the application server code. The transaction ends after the invoke of the applixcation server method, as the stack trace of an occurring exception shows:
    remote exception
    javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 0 No; nested exception is:
         org.omg.CORBA.TRANSACTION_ROLLEDBACK:
    org.omg.CORBA.TRANSACTION_ROLLEDBACK: com.ibm.websphere.csi.CSITransactionRolledbackException:
         at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:194)
         at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:67)
         at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:414)
         at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:1818)
         at de.gedas.svm.server.app.ejb.EJSRemoteStatelessNavigationEJB.findPersonenZulieferer(EJSRemoteStatelessNavigationEJB.java:964)
         at de.gedas.svm.server.app.ejb._EJSRemoteStatelessNavigationEJB_Tie._invoke(_EJSRemoteStatelessNavigationEJB_Tie.java:589)
         at com.ibm.CORBA.iiop.ExtendedServerDelegate.dispatch(ExtendedServerDelegate.java:506)
         at com.ibm.CORBA.iiop.ORB.process(ORB.java:2376)
         at com.ibm.CORBA.iiop.OrbWorker.run(OrbWorker.java:186)
         at com.ibm.ejs.oa.pool.ThreadPool$PooledWorker.run(ThreadPool.java:104)
         at com.ibm.ws.util.CachedThread.run(ThreadPool.java:137)
    So the application server code has no possiblity for special reaction to this error condition.
    How can I use TopLink to execute my SQL statement immidately, not at the the end of the transaction (which is out of the area of my code)? Only the transaction should end at the usual time, managed by the container.

    I don't think there is anyway to currently do this in a JTS managed environment, to handle the exceptions you could,
    - Make use of TopLink session ExceptionHandlers to handle the database errors during the JTS commit.
    i.e.
    uow.setExceptionHandler(yourExceptionHandler);
    or,
    - Let TopLink control the transactions instead of JTS.

  • Bulk Loading using remote sql statement execution

    Well, i have a different scenario. I want to bulk load the tables like we do in MySQL with LOAD LOCAL DATA sql command.
    I have a file populated with data, what sql statement would bulk load the data into specified table using that file?
    Adnan Memon

    In Oracle, you would either use the SQL*Loader utility to load data from a flat file or you would create an external table (9i and later) that loads the flat file.
    A quick example of the external table approach
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Store Date as Oracle Date as string for simplicity?

    I got this table (scaled-down):
       CREATE TABLE TBLSERVICES
         STORENBR CHAR(4 byte) NOT NULL,
         SERVICEDATE CHAR(10 byte) NOT NULL,
         CHECKNBR CHAR(6 byte),
         ORDER_START_TIME DATE NOT NULL,
         ITEMID CHAR(4 byte), 
         SERVERID NUMBER(18),
         SERVERNAME VARCHAR2(50 byte),
         ITEMQUANTITY NUMBER
    ) Function MakeServicesDatatable(byval onodesconfig as xmlnodelist) return datatable
           dim objDT as new datatable
           With objDt
                .Columns.Add("StoreNbr", GetType(String))
                .Columns.Add("Order_Start_Time", GetType(String))
           End With
           dim dte as string
           For Each onode As XmlNode In onodesConfig
                    If onode.InnerText = "5" Or onode.InnerText = "6" Then
                        objdr = objDt.NewRow
                        objdr("StoreNbr") = storenbr
                        dteYear = parentNode("Order_Start_Time").SelectSingleNode("Year").InnerText
                        dteMonth = parentNode("Order_Start_Time").SelectSingleNode("Month").InnerText
                        dteDay = parentNode("Order_Start_Time").SelectSingleNode("Day").InnerText
                        DteHour = parentNode("Order_Start_Time").SelectSingleNode("Hour").InnerText
                        dteMin = parentNode("Order_Start_Time").SelectSingleNode("Minute").InnerText
                        dteSecs = parentNode("Order_Start_Time").SelectSingleNode("Second").InnerText
                        dte = String.Format("{0}/{1}/{2} {3}:{4}:{5}", dteMonth, dteDay, dteYear, DteHour, dteMin, dteSecs)
                        objDR("order_start_time") = dte
                        objDt.rows.add(objdr)
                    end if
            next onode
            return objDT
    end function
    I call following:
    dt = MakeServicesDatatable(NodesWithData)
    WriteDataToDB(dt)
    Public Sub WriteDataToDB(ByVal dtServices As DataTable)      
            Dim altConnString As String = connString
            Dim queryString As String = "Select * from tblServces"
            Using connection As New OracleConnection(altConnString)
                Dim adapter As New OracleDataAdapter()
                adapter.SelectCommand = New OracleCommand(queryString, connection)
                Dim builder As OracleCommandBuilder = New OracleCommandBuilder(adapter)
                connection.Open()
                Dim ds As DataSet = New DataSet
                adapter.Fill(ds, "tblServices")
                For Each drService As DataRow In dtServices.Rows
                    ds.Tables("tblServices").ImportRow(drService)                
                Next drService
               adapter.Update(ds, "tblServices")
            End Using
        End SubIn a PL/SL SQL Query, I need to say something like this:
    - Lunch is anything before 3:00pm
    - Assume date is same as date of order start time
    select  storenbr,
            itemquantity
    from tblServices
    where order_start_time < DatePArt(order start time date) || 15:59:00 I don't know syntax for getting date portion of oracle date
    Problem is the order_start_time is stored as dd-mmm-yyyy.
    I need seconds also. Should I make order-start_time a string
    and convert to date in SQL statement.

    Hi Vinod,
    Create a varaible of type customer exit for RUNDATE.
    IF i_step = 1.
       select max (rundate) from /bic/prundate into zrundate.
      IF i_vnam = 'rundate'.
      l_s_range - low = zrundate.
      l_s_range- opt = 'eq'.
    append l_s_range into e_t_range.
    endif.
    Endif.
    hope it helps
    bhaskar

Maybe you are looking for

  • *** Can I change the position/font of the titles?

    I would like to create a slideshow of some of my pictures where the title is also visible. I can see the checkmark to make sure the title is there but I wonder if it's possible to change the location and font of the text. Is there a way to do this? C

  • Using a popup as a progress indicator.

    Hi All, I'm using Jdeveloper REL 1 (11.1.1.1.0) I'm relatively new to ADF development. Here's my use case: 1. Display a set of records that will be processed. 2. User selects OK button to process records 3. A popup is launched displaying a progress i

  • Transport Logical system  DEV To Production

    Hi friends, can you guys tell me how to transport Logical system from DEV system to Production system. please help me its urgent.. Thanks in Advance

  • Scaling

    Hallo, I edited an image in Photoshop. It has a height of 578 pixels and is 1120 pixel wide. The pixel-edge-ratio is set to D1/DV Pal (1,066). I am working with the german versions of those applications, so excuse me if some of the commands and label

  • Info about Castle Clash by IGG keeps popping up?

    For starters, I don't even have this app in my iPod. Everytime I am trying to use my iPod Touch I am constantly interrupted by this! It's really annoying and I just want it to stop popping up. It keeps taking me to the app store and showing the game