How to Update Date data type field value in oracle

I want to update records in a table that has a Date data type field. It's a oracle databse. I use the oracle thin drive to connect to the database. The everything works well, only when i try to update records that have date type value, something doesn't work.
I use the following stmt to update DB:
Class.forName("oracle.jdbc.driver.OracleDriver");
Conn = DriverManager.getConnection("jdbc:oracle:thin:@hostname:portnumber:schname", "uid","pwd");
stmt=Conn.createStatement();
String updStr = "UPDATE Article SET Archive = ' Disable' WHERE ArticleDate = # " + sqlDate +"# " ;
stmt.executeUpdate( updAStr ) ;
But I always got the SQLException run time error, which is "ORA-00911: invalid character"
Who can help me to find out how to write the above Update statement correctly? esp. that how to present the Date type variable in the statement.!
BTW, sqlDate is a Java.sql.Date variable, Is it "# " + sqlDate + "# " the right way?
Many thanks

What do you get out of Oracle's TO_DATE that java.sql.PreparedStatement.setDate()
won't give you? - MODWell, I don't know that I've used all capabilities of either, but when it comes to managing Date Strings my Oracle bias :) would be to code using Oracle's TO_CHAR and TO_DATE functions. Perhaps someone can tell me vendor neutral ways to do something simiilar to managing these input date/times (and hopefully just as easily, pretty much all done in a single line, single function)?
WHERE aDATE > TO_DATE('2010','YYYY')
WHERE aDATE > TO_DATE('2010 AUG 22','YYYY MMM DD')
WHERE aDATE > TO_DATE( 'January 15, 1989, 11:00 A.M.', 'Month dd, YYYY, HH:MI A.M.')
I believe most databases have something similar to this, although I have found Oracle's to be the most flexible and consistent, if not the most intuitive. Other vendors (DB2, SQL Server, Access) don't force you to always be explicit, and can accept a variety of date strings without masks. The problem is that while you might not be getting an error, it also may not be parsing your date as expected.
One could argue that this vendor specific hodgepodge of literal date/time strings is only one program modification away from disaster. They might be right.
Just to be clear. I'm not recommending using a vendor specific approach, but it's not a perfect world and somtimes you have to use what works easiest or best or fastest, and in some cases, that is the vendor specific alternatives.

Similar Messages

  • Can "SPML Web Service Complex Data Type field" take multiple values ?

    In Generic Technology Connector's -SPML design parameters section, Can we give multiple values in SPML Web Service Complex Data Type field?
    If not, how can i call methods directly instead of calling them through a values of the "name" attribute of the "complexType" element in SPML Web Service Complex Data Type?
    I need 'SPML Web Service Complex Data Type' to hold multiple values.And based on the request it has to initiate appropriate method of action.
    Presently i have three methods add,modify and delete which i am calling through a single value of the "name" attribute of the "complexType" element in SPML Web Service Complex Data Type.
    I want to replace this single value with multiple menthods , so that a direct interaction between the method,OIM and target can be established.
    Edited by: 821054 on 16/02/2011 04:23

    Thanks Robert.
    You'll need to create your own interface to the webapp database for those kind of data operations
    by this, are you speaking of the internal BC database which stores web app schema data? That would be great if it were possible to update that programmatically because I need to use the List (Checkbox List) field type (for the search functionality), but I need to supply the checkbox options from a web app rather than by manually updating the list entered in the Fields view of the web app settings (shown below).
    I'm curious if anyone else has tried this?
    Again, my reason for needing to use the List (Checkbox List) field type is that the page which processes searches knows to expect a comma separated list for this field type and then appears to be parsing out the individual values for searching out web app items with 1 or more matching values. You're right that text fields (string and multiline) just check for 'string contains' matches, and this would be ok if I was only ever needing to search just one value at a time. Here's an example of what I might do:
    Web App item field value (as recorded against the List (Checkbox List) field type:
    8294877,8294878
    Web App Search value (for this same field):
    8294879,8294877,8294885
    The search would return this web app item because the field contains 2 (1 or more) individual values even though they were entered into the search field in a different order. If this web app item were just a Text (string or multiline) field, the searched value is not a substring of the web app item's stored value, so it would not find a match. Hence the need to use Checkbox List field type.
    The web app will have thousands if not 10s of thousands of records, so dumping them all into one big array or object and searching on the front-end won't be practical (though it works great on smaller datasets).

  • How to check data type of the field symbol at run time

    Hi,
    My code is as following:
          LOOP AT <fs> ASSIGNING <wa_covp_ext>.
            ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
            IF sy-subrc = 0.
              ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
              IF sy-subrc = 0.
                  SELECT SINGLE sname INTO <f_zzname> FROM pa0001
                                WHERE pernr = <f_pernr>
                                AND endda GE sy-datum
                                AND begda LE sy-datum.
             ENDIF.
          ENDIF.
        ENDLOOP.
    This query is giving dump when <f_zzname> is type P length 8 and decimals 2, because it tries to put PA0001-sname into it which is type C length 30. So I want to check the type of <f_zzname> before the select statement. If it is character 30, then I will write the select statement else not.
    How to check data type of the field symbol at run time? If it's not possible, then can somebody suggest a workaround? Thanks.

    check this ...
    write describe statement  ...
    field-symbols : <f_zzname> .
    data : sname like pa0001-sname,
           typ(10).
    assign sname to  <f_zzname>.
    describe  field <f_zzname> type typ.
    write : typ. <-- typ contains character type in this case ..
    U can check if typ is of character(C) if so .. write the select statement ...

  • How to change data type of input parameter

    Hi
    In my procedure i declared the data type of "Value Date" Input parameter as Date where as in CR it is showing data type as "Date Time". Can any one please specify how to change to Date.
    While prompting for input parameter in description it is showing message as
    Please enter Date time in format"yyy-mm-dd hh:mm:ss" . To change the content selected "format field" option. But is there any way to change input parameter data type.
    Please suggest how to change.
    Thanks Sruthi

    Hi Sruthi,
    all you need to do on this is open the report go to the parameters, select the parameter that you wish to change and click "Edit". This will allow you to change thefield to a date rather than a date time.
    Regards,
    Noel

  • To find the date type fields in the row and validate those date fields

    TYPES : BEGIN OF TY_MARA,
              MATNR TYPE MARA-MATNR,
              ERSDA TYPE MARA-ERSDA,
              ERNAM TYPE MARA-ERNAM,
              LAEDA TYPE MARA-LAEDA,
              MTART TYPE MARA-MTART,
            END OF TY_MARA.
    DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
          it_mara1 TYPE STANDARD TABLE OF ty_mara,
           wa_mara TYPE ty_mara.
    loop at it_mara into wa_mara.
      describe field wa_mara-ersda type c_data.
    if c_data eq 'D'.
      CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
        EXPORTING
          date                            = wa_mara-ersda
       EXCEPTIONS
         PLAUSIBILITY_CHECK_FAILED       = 1
         OTHERS                          = 2
      IF sy-subrc eq 0.
    wa_mara-ersda = '00000000'.
        append wa_mara to it_mara1.
        write :wa_mara-matnr,wa_mara-ersda.
        else.
            wa_mara-ersda = '00000000'.
        append wa_mara to it_mara1.
        write :wa_mara-matnr,wa_mara-ersda.
      ENDIF.
      endif.
      endloop.
    This issue regarding how to find the date type fields in the row and validate those date fields.If its not a valid date ,i have to assign initial value to that.
    I've tried that for single field using describe field.Please help me do that for all fields.

    Hi Sam,
     I believe we had discussed the same issue in the below thread. Can you please refer the below one?
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d93e16ff-c123-4b36-b60b-60ccd34f6ca7/calculate-time-differences-in-infopath?forum=sharepointcustomizationprevious
    If it's not helping you please let us know
    Sekar - Our life is short, so help others to grow
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer

  • Update Date types based on actions

    Hi Gurus,
    I have a requirement to update date types within a date profile based on a certain action condition.
    I have 3 date types:
    Downtime Start
    Downtime End
    Total Downtime Duration
    The priorities in my transaction have, x, y, z for example and x is default.
    Upon selecting y, the system should take into consideration the timestamp of this change and update the Downtime Start... The moment the priority is changed to anything other than "y", it should take this timestamp and update "downtime end".
    The difference between these two times would be the third date type.
    Any ideas how to proceed?
    Regards,
    Ash

    Hi
    Please post DDL+DML next time :-)
    -- This is the DDL! create the database structure
    create table DateRange(
    StartDate DATE,
    FinishDate DATE,
    Condition BIT
    GO
    create table Calendar(
    CalendarDate DATE,
    IsParental BIT
    GO
    -- This is the DML (insert some sample data)
    insert DateRange
    values
    ('2014-01-02', '2014-01-03', 1),
    ('2014-01-03', '2014-01-13', 0),
    ('2014-01-13', '2014-01-14', 1)
    GO
    insert Calendar(CalendarDate)
    values
    ('2014-01-01'),
    ('2014-01-02'),
    ('2014-01-03'),
    ('2014-01-04'),
    ('2014-01-05'),
    ('2014-01-06'),
    ('2014-01-07'),
    ('2014-01-08'),
    ('2014-01-09'),
    ('2014-01-10')
    select * from DateRange
    select * from Calendar
    GO
    -- This is the solution
    select CalendarDate
    from Calendar C
    where EXISTS (
    select C.CalendarDate
    FROM DateRange D
    where C.CalendarDate between D.StartDate and D.FinishDate and D.Condition = 1
    UPDATE Calendar
    SET IsParental = 1
    from Calendar C
    where EXISTS (
    select C.CalendarDate
    FROM DateRange D
    where C.CalendarDate between D.StartDate and D.FinishDate and D.Condition = 1
    [Personal Site] [Blog] [Facebook]

  • How to Convert Data types here

    Hi All,
    My stored proc is as below,
    create or replace procedure proc_sec_synch (
    Begin
    FOR sec_Update in (
    Select
    SsM_ID ,
    CYCLE_DATE ,
    TARGET_TABLE ,
    COLUMN_NAME ,
    NEW_DATA  ,
    COLUMN_TYPE from PM_OWN.test_synch order by target_table
    Loop
    *'Update' || sec_Update.target_table ||' dest SET dest.' ||sec_Update.column_name||' =*
    *(select src.new_data from pm_own.test_synch src where src.ssm_id = '||sec_Update.target_table||'.ssm_id)'*
    END Loop;
    END proc_sec_synch;
    actually I'm updating different tables using one table. the one table consists all the data like target table name and column name and the values also.
    in the above query, the data type of value what I'm retreiving from pm_own.test_synch is different from target table column datatype.
    so how could I change the type of retreiving value to the destination table column data type.
    help me.

    Here is the answer...
    Actuallly I have two databases which I need to synch 2nd database using first database, synch in the not entore database but only few tables and only few columns and that too on specific where condotions. so I made so many queries and retreiving data into temp tables and then updating into target tables,
    instead of above what I'm trying is I have created a stagiing table where I'll update the data (by using all above seelect queries) and update the target tables in one shot withoput using temp tables.
    Bottom line is:
    I need to get the report for the data that is getting updated daily before updating.
    and before updating I should have previllage to decide whether to update or not..?
    Cheers,
    Naresh

  • How to get data type of variable in program..

    Hi ABAP Guru.
    I need to know how to get data type of variable or any structure field.. because I got short dump when use command REPLACE ALL OCCURANCE ... with variable/structure field that has data type I or P, I think it should be used with data type CHAR only, So I need to check the data type first.
    Please give me your advice
    Thank you all.
    Nattapash C.

    data : v_value type i,
             v_char(10) type c.
    v_value = 10.
    move v_value to v_char.
    REPLACE ALL OCCURRENCES of '#' from v_char....
    Best regards,
    Prashant

  • Importing an SQL Server TEXT data type field in Oracle - problem with LONG

    Hello,
    I work in Oracle 9i and I created a view on a distant SQL Server database that contains a TEXT data type field. But I have a problem when I select that field in Oracle; I have the following error message: "ORA-00997: forbidden use of LONG data type".
    Could anybody have a solution for me, to solve that problem?
    Thanks a lot!

    It is very difficult to suggest anything without seeing your code.  I don't even know if what you are seeing is the actual value or an error code.  Often, negative numbers are indicative of error codes. 
    For instance -1 could mean that you have an invalid reference or path, etc...
    Can you post your code?

  • How to change data type of attribute in caf

    hi.
    this is my problem.
    i been added a attribute in an entity service called emloyee. named "Birthday", use the data type "com.sap.caf.core.date".
    when i tried modify the entity service, i hit exception about "DST Daylight Saving Time".
    because of DST, the date will add an hour such like "1957/04/01 00:00:00.0" to "1957/04/01 01:00:00.0", and com.sap.caf.core.date will throw an exception.
    is anyone had same problem like me?
    how to fixed it(if passable)?
    and, how to change data type?
    thanks.

    Hi Sruthi,
    all you need to do on this is open the report go to the parameters, select the parameter that you wish to change and click "Edit". This will allow you to change thefield to a date rather than a date time.
    Regards,
    Noel

  • Insert current date and time into Oracle date type field

    I have a JDBC current date and time insert into Oracle 9i that almost works. It submits the current date and a fixed time into the Oracle date type field. I am using Tomcat 6.0.20.
    For example if I insert the data at 7:24:04 PM on Feb 16, 2010 it will insert as: 16-Feb-2010 12:00:00 AM
    The date part works but the time always shows 12:00:00 AM no matter what date or time the data is inserted.
    Here is what I have for my JDBC inserts and I also tried something with DateFormat:
    PreparedStatement ps; Date mydate = new Date(new java.util.Date().getTime()); //insert statement here.... stmt.setDate(1,mydate);
    I also tried:
    PreparedStatement ps; java.sql.Timestamp mydate = new java.sql.Timestamp(new java.util.Date().getTime()); SimpleDateFormat fmt = new SimpleDateFormat(.... //insert statement here.... ps.setTimestamp(1,fmt.format(mydate));
    Both keep submitting the date into Oracle as 16-Feb-2010 12:00:00 AM
    Anyway to get the current date and time? For example if I insert the data at 7:24.04 pm today it should show as 16-Feb-2010 07:24.04 PM in Oracle.

    sportsMarkr wrote:
    Date mydate = new Date(new java.util.Date().getTime());Please see the javadocs for java.sql.Date and note the part that says "...to zero"
    [http://java.sun.com/javase/6/docs/api/java/sql/Date.html]
    If you want a date and time then use java.sql.Timestamp.

  • How to update data according to row_number in sql

    hi,
    after deleting an item I need to update data according to row_number.
    in oracle database I have a code like this... working perfectly..
    update regitem set line_sn= LPAD(ROWNUM,2,'0') where doc_no='" & mydocno & "'
    how it will work in sql server...
    thanks..........

    There is an example at the below link which uses the Transact SQL ROW_NUMBER():
    http://stackoverflow.com/questions/6729616/sql-server-how-to-update-a-column-for-a-desired-row-number
    Paul ~~~~ Microsoft MVP (Visual Basic)

  • Infotype 0041  - Date type field in display mode always

    Hi All,
    Please help in find out solution for the below enhancement
    In infotype 0041 we have date type and date field. We need to make the date type field to be display mode always.
    Thanks for your help in advance.
    Thanks,
    Karthikeyan

    Hi Karthikeyan ,
    Please find the resolution as below :
    Userexit - EXIT_SAPFP50M_001 . In Include ZXPADU01. Write the below code .
    DATA: w_P0041 TYPE P0041.
    IF  ipsyst-massn <> space AND
      ( ipsyst-ioper = 'INS'  OR
        ipsyst-ioper = 'INSS' OR
        ipsyst-ioper = 'COP'  OR
        ipsyst-ioper = 'MOD').
    CASE innnn-infty.
    WHEN '0041'.
    *convert prelp to pnnnn structure
    CALL METHOD CL_HR_PNNNN_TYPE_CAST=>PRELP_TO_PNNNN
    EXPORTING
    PRELP = INNNN
    IMPORTING
    PNNNN = w_P0041 .
    *Here you can have more conditions like for which Action Types you want the
    IT0041 to default .
    w_P0041-dar01 = 'Z1'.
    w_P0041-dar02 = 'Z2'.
    w_P0041-dar03 = 'Z3'.
    *convert pnnnn to prelp structure
    CALL METHOD CL_HR_PNNNN_TYPE_CAST=>pnnnn_to_prelp
    EXPORTING
    PNNNN = w_P0041
    IMPORTING
    PRELP = INNNN.
    *Display mode
    LOOP AT SCREEN.
              IF screen-name = 'P0041-DAR01' OR
                 screen-name = 'P0041-DAR02'  OR
                 screen-name = 'P0041-DAR03'  .
                CLEAR screen-group2.
                screen-input = 0.
                MODIFY SCREEN.
              ENDIF.
            ENDLOOP.
    WHEN OTHERS.
      ENDCASE.
    ENDIF.
    Thanks ,
    Sucharita Das

  • How to crete data type from XSD

    Hi All,
    can anyone tell me ...how to create data type from agiven xsd.
    I need urgently....
    thanks in advance....

    import this XSD, load this in your mapping editor and then use this to crate the datatype manually.
    Or, use XML spy, load this XSD and then you should be able to see the Structure, or,
    Look into the XSD data and decipher things yourself
    Regards
    Bhavesh

  • Want to Have INT4 Data type field in IT

    Dear All,
               I want INT4 Data type field in my Customized infotype field.
               Is it possible to have it with signs.
    Thanks
    Satya.

    Hello Satya
    you cant have INT4 as datatype in your custom infotype
    Reward points if helpful

Maybe you are looking for

  • Error: "Not logged on in interface XBP"

    We are developing an external monitoring tool to call CCMS Bapi's via RFC calls. As per the documentation, we are opening RFC connection and then calling function module(BAPI). When we pass the BAPI, we get the error message "Not logged on in interfa

  • Can not boot from a RAID 5 volume

    Dear Friends, I have a Mac Pro (3 GHZ) with RAID that will not boot off of a RAID 5 volume. Here's the details: The unit has 4 768 GB drives that I have made into one RAID 5 set. After that I broke it down into 2 two volumes one for OS (200 GB) and o

  • Missing class/interface?

    I'm just starting out w/ JDev. Tried the BC client tutorial and ran into the following error when compiling: C:\java\BC4J\src\bc4jaddinsrc.zip!\oracle\jbo\domain\DomainInterface.java Error(14,19): cannot access class oracle.jbo.Transaction; file orac

  • Index not used for search

    Hallo all, I created some Indexes that I select in the advanced search options. I even reindexed them for being sure that the documents are listed in there. Now if I'm searching for properties, title, text, or something else no one of the documents g

  • SP online 365 - Unable to render the data. If the problem persists, contact your web server administrator.

    Help needed urgently, i'm pulling my hair out on this one! Using SharePoint online (365) I am trying to create an external list to a SQL table. I go through the steps in SP designer and finally create the external list but when I go to the list I get