Oracle OCI: Problem in Query with Date field

Client compiled with OCI: 10.2.0.4.0
Server: Oracle9i Enterprise Edition Release 9.2.0.4.0
The problematic query is:
SELECT CODIGO FROM LOG WHERE TEL = :telnumber AND DATE_PROC = '05-JUL-08'Table description:
SQL>describe LOG;
TEL NOT NULL VARCHAR2(15)
CODIGO NOT NULL VARCHAR2(20)
DATE_PROC NOT NULL DATEAs simple as it might look, when executed directly on the server with SQLPlus, it returns a result, but when executed from the app that uses OCI, this query returns OCI_NO_DATA always. In the beginning, the date value was also a placeholder, but I found out that even giving a literal like '05-JUL-08' didn't work. I have tried the following:
<ul>
<li>I've tried the basics: querying the DB from the client does work. It's this one that gives me trouble</li>
<li>The query: SELECT CODIGO FROM LOG WHERE TEL = :telnumber does work</li>
<li>Executing: ALTER SESSION SET NLS_DATE_FORMAT="DD-MM-YYYY"; before the query in both the server and the client. Same result: server returns data, client OCI_NO_DATA</li>
<li>Tried changing DATE_PROC format, combining this with the use of TO_DATE(). Same result.</li>
<li>Searched, searched, searched. No answer</li>
</ul>
I'm a bit desperate to find an answer, would appreciate any help and can provide as many further details as needed. Thanks.
Edited by: user12455729 on Jan 15, 2010 5:59 AM. -Formatting-

Hi,
I've recreated your table and populated with your data.
I've run your select using OCILIB on a 10gR2 (client and server) and the codes runs fine and give expected results.
So the problem must resides in your code.... (i don't think it can be a OCI bug)
Here is the ocilib code :
#include "ocilib.h"
int main(void)
    OCI_Connection *cn;
    OCI_Statement *st;
    OCI_Resultset *rs;
    char msisdn[100] = "11223344";
    char datetime[100] = "";
    if (!OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT))
        return EXIT_FAILURE;
    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
    st = OCI_StatementCreate(cn);
    OCI_Prepare(st, "SELECT "
                    "  CODIGO_BANCO "
                    "FROM "
                    "  VTA_LOG "
                    "WHERE "
                    "  TELEFONO = :msisdn AND "
                    "  FECHA_PROCESO = TO_DATE(:datetime, 'YYYYMMDDHH24MISS')");
    OCI_BindString(st, "msisdn", msisdn, sizeof(msisdn)-1);
    OCI_BindString(st, "datetime", datetime, sizeof(datetime)-1);
    strcpy(datetime, "20080705162918");
    OCI_Execute(st); 
    rs = OCI_GetResultset(st);
    OCI_FetchNext(rs);
    printf("%s\n", OCI_GetString(rs, 1));
    strcpy(datetime, "20080705062918");
    OCI_Execute(st); 
    rs = OCI_GetResultset(st);
    OCI_FetchNext(rs);
    printf("%s\n", OCI_GetString(rs, 1));
    OCI_Cleanup();
    return EXIT_SUCCESS;
}Output is :
BancoOne
BancoTwoi recreated your data with
create table VTA_LOG
     TELEFONO          VARCHAR2(15) NOT NULL ,
     CODIGO_BANCO     VARCHAR2(20) NOT NULL ,
     FECHA_PROCESO     DATE NOT NULL
insert into VTA_LOG values ('11223344', 'BancoOne',  to_date('20080705162918', 'YYYYMMDDHH24MISS'));
insert into VTA_LOG values ('11223344', 'BancoTwo', to_date('20080705062918', 'YYYYMMDDHH24MISS'));
commit;Regards,
Vincent

Similar Messages

  • Problem with date fields in where clause after changing driver

    Hi,
    We have changed the oracle driver we use to version 10
    and now we have some trouble with date-fields.
    When we run this SQL query from our Java program:
    select *
    from LA_TRANS
    where LA_TRANS.FROM_DATE>='20040101' AND LA_TRANS.FROM_DATE<='20041231'
    We get this error code:
    ORA-01861: literal does not match format string
    The query worked fine whit the previous driver.
    Is there some way I can run a SQL query with date fields
    as strings in the where clause?
    Thanks!

    Keeping the argument of standard SQL or not aside, comparing DATE columns to a constant string (which looks like a date in one of the thousands of the formats available, but not in others) is NOT one of the best programming practices and leads to heartburn and runtime errors (as you have seen yourself).
    I would rather compare a DATE to a DATE.
    Also, constants like that would be another issue to fix in your code:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:6899751034602146050::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:528893984337,

  • Help with Date Field properties

    I have a problem setting properties for date field. I want date in mm/dd/yy format, that i am able to but I want something like this. When someone enters date as just numbers like 080708, it should automatically make it as 08/07/08.
    I tried doing some setting but couldn't find any help appreciated.
    thanks

    You will need to adjust the validation patterns in the Value tab on the object palette. There are four patterns that you can play with (Display, Edit, Validation and Data). Each pattern will affect the field data at different times. To get access to the patterns click on the Validation Pattern...button. A new dialog will open up with the 4 patterns available to you. The display pattern is how the data will be shown on screen. The edit pattern is how the user will enter the data, the Validation pattern is how the field will be validated and the Data pattern is how the data will appear in the saved XML.
    In your case you will want to set a disply pattern of DD/MM/YY and an edit pattern of DDMMYY. This will allow the user to enter 080708 or 08/07/08 and it will display 08/07/08 all of the time.
    Hope that helps

  • Problems While Working With CLOB fields

    HI Friends,
    I am facing one big problem while working with CLOB fields. I work in crystal reports in my project and My team is works in BMC Remedy tool. As per database configuration by default the date fields are stored in numbers. There is a field named Work Log which stores the complete history information of a ticket or a call.
    While generating reports I convert the date fields from numbers into date values by using to_date function. But I am not able to change the dates mentioned in the worklog which is a CLOB field. As a result when I am generating reports text part of the work log is comming fine but the date fields are comming in numbers.
    Please refer the below example:-
    *1291012455anilkumarptesting*
    Full Name:
    PRG Name - EUC-APP PKGN1291012585anilkumarptesting
    Full Name:
    PRG Name - EUC-APP PKGN1291012631anilkumarptest
    Full Name:
    PRG Name - EUC-APP PKGN1291207510anilkumarpfd
    Full Name: Anil Kumar Pantangi
    PRG Name - Prod_Ops1291207535anilkumarpf
    Full Name: Anil Kumar Pantangi
    PRG Name - Prod_Ops
    Assignment notification disabled for this transaction1291212517kapilbasd
    Full Name: Anil Kumar Pantangi
    PRG Name - Prod_Ops
    See the first line of the worklog "1291012455anilkumarptesting", 1291012455 is referring a date value, but due to database configuration it's comming in number. All the other numbers in the above text are dates only which need's to be converted. These dates are captured in remedy tool when someone updates that ticket.
    I am not able to decide how to change this numbers into dates. As it is containing lot's of numbers i am really confused how to come with a solution.
    Can I expect a solution from you, atleast a way how to proceed resolving this problem. Should I have to write a procedure for this??
    Please help..........
    Kindly let me know if you need any more input.
    Regards,
    Arijit

    937670 wrote:
    1291012455 represents a date value,What date value does it represent? Since it's not obvious to us what date you want that converted into, it's obviously hard for us to help. For example, perhaps you want that to be Jan 29, 2010 with "12455" representing a time component in some non-obvious format. Perhaps you want that to be December 1991 at 1:24:55. Perhaps you want to convert it to a completely different date. You're going to need to tell us in words how to convert your numeric data into a date.
    My question is how can I convert all the numbers into date in the CLOB field and present it in a proper manner.Given your sample data, what do you expect the output to be? Do you expect many rows of data, one for every date in the CLOB? Do you expect a comma-separated list? Something else?
    Justin

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • Problem in query with the u0091Document numberu0092

    Hi,
    I got problem in query with the ‘Document number’
    There are three columns in the cube 1) Document number 2) Country 3) Count
    In the cube there are multiple entries for same document number as below.
          Document number            country          Count
         10000               US          1
         10001               US          1
         10002               US          1
         10002               US          1
         10002               US          1
         10003               UK          1
         10004               IN          1
         10004               IN          1
    When I ran the query on this cube for country US it shows count as 5 but I want count as 3 (i.e. it has to take count only once for the same document no’s)
    Similarly for country IN I want count as 1

    Hi,
    You have to create a counter based on the document number (exception aggregation). There is a How-to paper available for this. It is called: How-to...count the occurences of a characteristic.
    Regards,
    P.

  • Oracle reports problem in distribution with xml file

    Hi ,
    I am having problem while I am trying to distribute the file with specifing the destination details in the xml. If I am giving the destination details in url then it is working.
    Ex.
    This is Working
    http://bryxh91:8889/reports/rwservlet?report=devlopersuit/reports/test.jsp&userid=anju/[email protected]&desformat=pdf&destype=file&desname=devlopersuit/reports/output_file.pdf
    Not working :
    http://bryxh91:8889/reports/rwservlet?report=devlopersuit/reports/test.jsp&userid=anju/[email protected]&DISTRIBUTE=YES&destination=devlopersuit/reports/dis_test.xml
    xml file
    <destinations>
    <file id="test" name="output_file.pdf" format="pdf">
    <include scr="mainSection"/>
    </file>
    </destinations>
    Error : REP-34304: Distribution failed to complete; review the distribution lists
    Its been week I tried many things , but not working.
    Right now I am trying to distribute to single file but my goal is to burst and distribute on basis of account number.
    This is the first stage of the project.
    Thanks a lot for the help
    Anju

    Hello
    see answer in Oracle reports problem in distribution with xml file
    Regards

  • SQ02 - Query with adicional fields

    Hi, I need your help to develop a query with additional fields.
    The case is that:
    In my query I only have a table VBAK and my propose is that this query returns me the quantity that are in a sales document for some material that should be selection parameters.
    So I create 2 additional fields: one that is the u2018 Material u2018 that have no codification and other that is the quantity that have the code:
    select single ZMENG into quantity from VBAK where matnr = material.
    But the result is null, I don't know why.
    Can you help me?
    Thanks in advance.
    Dora

    Hi,
    MATNR is not available in VBAK !
    You have to create first an info-set using SQ02 : here you link VBAK and VBAP, and select the fields you need.
    From SQ01, create a new query where matnr is a selection field ....

  • Writing query to Oracle DB with DATE field in it.

    When I try to execute the following query on Oracle DB I get an exception. I know that the problem is with Date representation on the query string. Please, if anyone knows how to make it work help me.
    query = "INSERT INTO MYTABLE (NAME , BIRTHDAY ) VALUES ('" + person.getName() +" ' , " + person.getBirthday() + " )";
    statment.executeUpdate(query);
    getBirthday() returns java.sql.Date object.
    Please, please, help to work it out!

    Thank you, very much.
    I've put the record into DB!!!! Hurray!
    But now I have another problem. I've got a ResultSet & I'd like to extract the DATE from it. But how?
    The Exception text states that the name of the field (Birthday) is incorrect.
    My code:
    Date birthday = resultSet.getDate("Birthday");
    All other fields are perfectly well extracted, but they are Strings.

  • Querying a date field with different masks in form and database

    Dear friends,
    I have a field with date format mask dd/mm/yyyy hh24:mi:ss, but the same field has date format dd/mm/yyyy inside the form which queries it.
    If I run this form, obviously I will query this date in dd/mm/yyyy format mask, but this date is not being found because it doesn't include hh24:mi:ss (hour) from the database field.
    How can I solve this problem? I tried to change my form, putting a format mask with hours, but it requires me to query this date with time, and obviously no one needs to know the exact moment (with seconds!) when the date was recorded in the database.
    Thanks, and best regards,
    Franklin

    Franklin,
    You could instruct your users to use the '%' when they enter a date search criteria. Another alternative would be to programatically add the '%' to the date. Also, if your Block based on a view you could alter the vuew to use TRUNC() on the date field to drop the time.
    Another option would be to use the Pre-Query trigger to modify the Block WHERE clause to: TRUNC(date_field) = :block.date_field.
    Hope this helps.
    Craig...
    -- If my response or the response of another is helpful or answers your question, please mark the response accordingly. Thanks!

  • JHeadstart query operator between with date field

    Hallo,
    I am using JDeveloper 10.1.1.0.2 and JHeadstart 11 Technical Release 1.
    In my Application Definition Editor I use the Query Operator 'between' on a data-field. In my Application I can see a 'from' and 'to' date field.
    Testcase:
    In my table I have 3 dates: 1-1-2009, 17-1-2009 and 18-1-2009.
    If I use:
    Date from: 1-1-2009 and Date to: 18-1-2009 in my Application I expect to see only 2 rows (1-1-2009 and 17-1-2009). But I can see 3 rows.
    So my question is: what does 'to' mean in the JHeadstart generator? Does it include the date you fill in with the 'to' field?

    I can change the text in GeneratorText_nl.properties, but this does not completely solve my problem.
    I use a DateTimeField in my Application and if I use 'Date to' in my search criteria it seems that the Time of my Date-field is being ignored!
    Testcase:
    'Date to' in searchcriteria = 13-10-2009 *12:10:00* also gives results with the same date but time greater than 12:10:00, for example 13-10-2009 *16:10:00*.

  • Problem with Date fields in Search panel

    Hi all,
    I use TP2 and in my jspx page I have a search panel with two date fields and table where the results is displayed. But there is a problem with these date fields, because when I search dates the results is nothing even I retype the date from table. Also I have other pages where this problem exist with same structure.
    Could somebody help me with some advice?
    Thanks in advance!

    Hi Frank,
    Thanks for the answer.
    I use the standart method to make search panel with drag and drop the data control to the page. The other search panel fileds work fine, only the date fileds are problem. Maybe something in view object doesn't work properly.
    Here I post the code from my page.
    <table border="1" style="margin:5px;">
    <tr>
    <td>
    <af:showDetailHeader text="ТЪРСЕНЕ" disclosed="true"
    inlineStyle="width:780px;">
    <table cellspacing="2" cellpadding="3" border="0">
    <tr align="left">
    <td align="right">
    <af:outputLabel value="#{bindings.EGN.hints.label}"/>
    </td>
    <td align="left">
    <af:inputText value="#{bindings.EGN.inputValue}"
    label="#{bindings.EGN.hints.label}"
    columns="#{bindings.EGN.hints.displayWidth}"
    maximumLength="#{bindings.EGN.hints.precision}"
    simple="true"/>
    </td>
    <td align="right">
    <af:outputLabel value="#{bindings.LNC.hints.label}"/>
    </td>
    <td align="left">
    <af:inputText value="#{bindings.LNC.inputValue}"
    label="#{bindings.LNC.hints.label}"
    columns="#{bindings.LNC.hints.displayWidth}"
    maximumLength="#{bindings.LNC.hints.precision}"
    simple="true"/>
    </td>
    <td align="right">
    <af:outputLabel value="#{bindings.AccPersonID.hints.label}"/>
    </td>
    <td align="left">
    <af:inputText value="#{bindings.AccPersonID.inputValue}"
    label="#{bindings.AccPersonID.hints.label}"
    columns="#{bindings.AccPersonID.hints.displayWidth}"
    maximumLength="#{bindings.AccPersonID.hints.precision}"
    simple="true"/>
    </td>
    </tr>
    <tr align="left">
    <td align="right">
    <af:outputLabel value="#{bindings.PersonName.hints.label}"/>
    </td>
    <td align="left" colspan="5">
    <af:inputText value="#{bindings.PersonName.inputValue}"
    label="#{bindings.PersonName.hints.label}"
    columns="#{bindings.PersonName.hints.displayWidth}"
    maximumLength="#{bindings.PersonName.hints.precision}"
    simple="true"/>
    </td>
    </tr>
    <tr align="left">
    <td align="right">
    <af:outputLabel value="#{bindings.DateFrom.hints.label}"/>
    </td>
    <td align="left">
    <af:inputDate value="#{bindings.DateFrom.inputValue}"
    label="#{bindings.DateFrom.hints.label}"
    simple="true">
    <af:convertDateTime pattern="#{bindings.DateFrom.format}"/>
    </af:inputDate>
    </td>
    <td align="right">
    <af:outputLabel value="#{bindings.DateTo.hints.label}"/>
    </td>
    <td align="left">
    <af:inputDate value="#{bindings.DateTo.inputValue}"
    label="#{bindings.DateTo.hints.label}"
    simple="true">
    <af:convertDateTime pattern="#{bindings.DateTo.format}"/>
    </af:inputDate>
    </td>
    </tr>
    <tr>
    <td align="right">
    <af:commandButton actionListener="{bindings.Execute.execute}"
    text="#{bundle.FindBtn_LABEL}"
    disabled="#{!bindings.Execute.enabled}"
    icon="/images/find.png"/>
    </td>
    <td align="left">
    <af:commandButton text="#{bundle.FindClearBtn_LABEL}"
    icon="/images/find_clear.png"
    action="#{PeopleBean.onClearVCBtn}"/>
    </td>
    </tr>
    </table>
    </af:showDetailHeader>
    </td>
    </tr>
    </table>
    Also I have a result table for the search panel, but I don't believe the problem can be there because it works fine when I search in fields different by inputDate.
    Do you have any suggestions?

  • Problem with Date-Field

    Hi,
    I have a problem with a date-field. Maybe I must describe the problem more detailled, but first I just want to ask you, if you know the following error-message: "21.10.2010 kommt nicht in der Menge der erlaubten Werte vor". I don't know the correct translation but it must be something like this: "21.10.2010 does not occur in the quantity of the permitted values". I don't find the position in the sourcecode of this message. And I know, that this message isn't thrown by a functionblock from SAP. So what is the describtion of this message?

    Yes I have a date field in my form. Ok I must describe it more detailled. I have an employee searchfield. After select an employee you see a form. After filling the form you click on "Send". It creates a ticket and sends the data to the Backend and jumps back to the employee search field. Untill this point everything works fine. There is no problem with the datefield. Now I want to create the form. I choose an employee and fill the form. But now it comes this message. But not after clicking the "send" button. The message comes after changing some data (e.g. change a radio button). So it looks like a validationproblem, but only at the second creationprocess. Maybe the first date is in some cache? I don't know...

  • Problem in passing a date field to initilaize a VO query

    Hi,
    I am stuck with date issue
    I am passing end date to a VO query as parameter.
    this date is oracle.jbo.domain.date
    public void initQuery(Number swapHeaderId, Date start_date, Date end_date)
    setWhereClauseParam(0, end_date);
    When i print this end_date I get 2011-08-15
    In VO query I have mentioned
    Select Srsf.Swap_Header_Id From Sfifin.Sfi_Rm_Swap_Fills Srsf ,Sfifin.Sfi_Rm_Swap_Header Srsh, Sfifin.Sfi_Rm_Offer_Lines Srol Where Srsf.Swap_Header_Id = Srsh.Swap_Header_Id
    And Srol.Offer_Line_Id = Srsf.Offer_Line_Id And Srol.Offer_Header_Id = Srsf.Offer_Header_Id And Srsf.Swap_Header_Id = 124
    And to_char(Srol.End_Date,'YYYY-MM-DD') > to_char(to_date(:1,'YYYY-MM-DD'),'YYYY-MM-DD')
    Now when this Vo executes I get this error.
    java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
    I have tried all means but am unable to solve this issue.I have even tried to use
    Srol.End_Date>to_date(:1,'YYYY-MM-DD') in where clause but still the same error when I am hardcoding this parameter its working fine .
    Please help.

    setWhereClauseParam(0, end_date);Change this to
    setWhereClauseParam(0, end_date.toString());In VO query change
    Srol.End_Date > TO_DATE((to_char(trunc(to_date(:1)),'DD-MON-YYYY') ),'DD-MON-YYYY')Hope it helps!!
    Thanks
    AJ

  • Problem with date field (truncation)

    Hi guys!
    I have an interface between Oracle and Oracle. My LKM is SQL to SQL and my IKM is SQL Control Append.
    In the source table i have a date with a hour but after executing the interface in the target date field I receive only date without hour...
    Do you know where it can be truncated ?
    With regards,
    PsmakR

    This an Oracle JDBC Driver error...
    Try this to fix the issue:
    Go to Topology Manager and from the Physical Architecture > Technologies > Oracle > your Data Server > Properties tab, add the oracle.jdbc.V8Compatible property and set its value to true.
    Doing that you can loose the millisecond precision for timestamps format.
    You can also have a try with the Oracle JDBC Driver version 11.1

Maybe you are looking for

  • PERSONALIZATION AND PASSING PARAMETERS

    i created a button in OA personalization that luanches a URL. This URL requires parameters to be passed. I found the view object and view attributes in the page definition, but when I pass the URL as follows: http://usciapp04.utilityservice.com:59204

  • Rain Water Damage

    When we had heavy rain in England a few weeks ago, I had to take my iPhone out in order to use maps and find some directions as well as make a call. I put it back in my pocket asap and all seemed fine. However, as the day went on my phone kept going

  • Compiling datas from different sheets automatically

    Hhello all, here is my problem: -I created a file with several spreadsheets, one per year. -In each spreadsheet I have 12 tables, one per month, each containing the rows for each day. -Everyday I collect information (gas consumption) to put in the ta

  • Profile access?

    I have a contract with 3 lines. One of those lines have been suspended but the carrier of that phone has my SSN for changing the number to that phone the other day. I am wondering if that user can access my Verizon profile with my SSN? if so how woul

  • Samsung s4 status bar issue

    After upgrade tp kit kat I cannot get the status bar to drop down when I swipe it.  Cannot see the notifications