Inserting Date AND Time using DBMS_XMLStore.insertXML

Hello,
I'm using a c# app to create an xml file to be passed to a stored procedure. The store procedure then uses DBMS_XMLStore.insertXML to insert the record in the xml file into the database.
There is a field in the Oracle table called "ENTER_DATE". I've been putting a date into the xml file for this field (ie. "10-mar-2010") and this has worked fine. However, I've now been asked to include the time with the date.
Is it possible to somehow put a date AND time value in the xml tag value so that DBMS_XMLStore.insertXML will properly insert it into the Oracle table? Everything I try returns a date picture format error.
Thanks

SQL> create table dept2
as
   select d.*, sysdate enter_date
     from dept d
    where 1 = 2
Table created.
SQL> select * from dept2
no rows selected.
SQL> alter session set nls_date_format='dd.mm.yyyy hh24:mi:ss'
Session altered.
SQL> declare
   ctx   dbms_xmlstore.ctxtype := dbms_xmlstore.newcontext ('dept2');
   doc  xmltype
      := xmltype('<START>
               <ROW>
                 <DEPTNO>10</DEPTNO>
                 <DNAME>ACCOUNTING</DNAME>
                 <LOC>NEW YORK</LOC>
                 <ENTER_DATE>10.10.2010 23:11:16</ENTER_DATE>
               </ROW>
                     </START>');
   ret   int;
begin
   ret := dbms_xmlstore.insertxml (ctx, doc);
   dbms_xmlstore.closecontext (ctx);
end;
PL/SQL procedure successfully completed.
SQL> select * from dept2
    DEPTNO DNAME          LOC           ENTER_DATE          
        10 ACCOUNTING     NEW YORK      10.10.2010 23:11:16 
1 row selected.

Similar Messages

  • Unable to insert date and time when using date datatype

    Hi
    I am hitting a bit of a problem when using the date datatype. When trying to save a row to the table where the field it throws an error ora 01830 and complains about converting the date format picture ends...etc. Now when I do the insert, I use the to_date function with the format of "dd-mon-yyyy hh24:mi:ss". Of course, when I remove the time element, everything is perfect.
    Checking sysdate, I noticed that the time element wasn't be displayed, and I used alter session set nls_date_format to set the date and time I want to save to the table, which worked!
    Then based on advice in a previous thread to permanently fix the problem, I used alter system set nls_date_format ="dd-mon-yyyy hh24:mi:ss" scope=spfile; This showed that it was altered, and I can see the setting in the em. In sqlplus, I shutdown the database, and restarted with startup mount; alter database open; and then selecting sysdate, it still shows the date as dd-mon-yy, and still no time! Checking the em, and looking up the nls_date_format the setting is still shown as "dd-mon-yyyy hh24:mi:ss".
    So, my question is this - what am I doing wrong? Why can't save date and time using date in Oracle 11g?????
    Thanks

    user633278 wrote:
    Hi
    I am hitting a bit of a problem when using the date datatype. When trying to save a row to the table where the field it throws an error ora 01830 and complains about converting the date format picture ends...etc. Now when I do the insert, I use the to_date function with the format of "dd-mon-yyyy hh24:mi:ss". Of course, when I remove the time element, everything is perfect.
    Checking sysdate, I noticed that the time element wasn't be displayed, and I used alter session set nls_date_format to set the date and time I want to save to the table, which worked!
    Then based on advice in a previous thread to permanently fix the problem, I used alter system set nls_date_format ="dd-mon-yyyy hh24:mi:ss" scope=spfile; This showed that it was altered, and I can see the setting in the em. In sqlplus, I shutdown the database, and restarted with startup mount; alter database open; and then selecting sysdate, it still shows the date as dd-mon-yy, and still no time! Checking the em, and looking up the nls_date_format the setting is still shown as "dd-mon-yyyy hh24:mi:ss".
    So, my question is this - what am I doing wrong? Why can't save date and time using date in Oracle 11g?????
    ThanksYou most certainly can save the time. A DATE column, by definition stores date and time. What you describe is a presentation problem, and setting nls_date_format at the system as an init parm is the weakest of all settings as it is overridden by several other locations.
    without seeing the exact sql that produced the error (not just your description of what you think you were doing) it is impossible to say for sure.
    However, I'd suggest you read http://edstevensdba.wordpress.com/2011/04/07/nls_date_format/

  • Insert date and time

    This is a simple question but one that has been bugging me in a small way. If on a spreadsheet I press 'insert date and time' all I get is that day and date for example saturday 10th July 2010 and no time.
    Anyone offer an explanation for this?
    Thanks
    Mike

    Hello Peggy
    The problem was already reported to Bugs Hunters :
    +Bug ID# 7862838.+
    +In Numbers and Pages there is the function+
    +Insert > Date Time.+
    +At this time, its default behaviour is : insert the current date and the time 12:00:00 (without displaying the time).+
    +Given my own experience and what is often asked in Discussions forums, it would be interesting to change the default setting so that it inserts the current date & time and display both of them.+
    +Of course some users wish the availability of three items:+
    +Insert > Date defaulting to the sole date component+
    +Insert > Time defaulting to the sole time component+
    +Insert > Date & Time defaulting to the complete current dateTime.+
    +I preferred the scheme defaulting with the complete current dateTime because removing one component is faster than adding one using the existing protocol.+
    Yvan KOENIG (VALLAURIS, France) samedi 10 juillet 2010 19:05:47

  • Find record insert date and time in a table

    Hi All,
    I want to get record insert date and time in a table. There is no datetime column in my table. Are there any possibility to get date and time for each record?
    Thank You

    Thats not easy. If your transaction info still resides on active portion of the log you can use fn_dblog to read out the time at which the transactions occurs. This is useful only if you try it shortly after transaction.
    the code would look like this
    SELECT *
    FROM fn_dblog(null,null)
    WHERE [Transaction Name] LIKE 'INSERT%'
    OR [Transaction Name] LIKE 'UPDATE%'
    Also see
    http://www.mssqltips.com/sqlservertip/3076/how-to-read-the-sql-server-database-transaction-log/
    http://solutioncenter.apexsql.com/read-a-sql-server-transaction-log/
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Problem with getting current date and time using oracle.jbo.domain.Date

    I`d like to get current date and time using oracle.jbo.domain.Date method getCurrentDate(), but it always return current date and 12:00:00. I also need to get the current time.

    I think you should use java.sql.Timestamp domain.
    (And set database type to TIME or DATETIME.)
    Jan

  • Inserting Date and Time into a date field

    Okay I am a bit of a Oracle newbie. I am trying to insert the following date and time into a date field and I don't know how to format the second part of the to_Date() function.
    Date/Time: 5/29/2003 7:58:45 PM
    Thanks,
    Branden

    I believe you would want
    to_date( '5/29/2003 7:58:45 PM', 'MM/DD/YYYY HH:MI:SS AM' )
    Note that tahiti.oracle.com has all of Oracle's documentation, including the very useful SQL & PL/SQL reference manuals, available for free.
    Justin

  • Help please on inserting date and time on iWeb

    I am using iWeb '09 (which I love) to manage the website for our HomeOwners Assocation.
    http://www.seabridgehh.com/seabridgehh.com/Home.html
    I have downloaded a script to insert the current date and time - which works, but............
    has anyone got a clue on how to re-format the font and colour please?

    Julian:
    This demo page has examples of date and time added to a page. The text versions are not self updating. The embedded flash version is. There may be a way to have the text version update every second or minute depending on what you have displayed but I've not found it in my searches to date:
    OT

  • Insert date and time into write to spreadsheet

    Easy question here
    I need save 4 arrays of data and insert the date and time that it was taken (LV 8.6)
    for example
    9/4/09 10:00:01 AM  4  6  7  2
    9/4/09 10:00:02 AM  4  6  7  2
    9/4/09 10:00:03 AM  4  6  7  2
    9/4/09 10:00:04 AM  4  6  7  2
    Any ideas, I can't wire the timestamp or date/time string right into the create array
    Thanks
    Chris
    Solved!
    Go to Solution.

    Ok
    the basic problem that I see is the the LabVIEW TimeStamp type is a cluster.  Converting it to a dbl gives you a value in seconds elapsed since 1904 Jan 1 12:00AM GMT and, your spreadsheet cannot interprate that (or display that) as a "TIME."   So, you want to convert it to a string (easy TS->String check the help for format options) BUT, you might want to pass all of your data as numbers into your spreadsheet so you can post-calculate or graph other outputs vs. TIME!  This little chunk of code .....
     converts a LV Timestamp to a number that Excel interperates as "the amount of days elapsed since 0 Jan 1900 @ 12:00AM LOCAL."  You will need to format the cell in Excel to display it as a date-time But it can be operated on and graphed against with only Excel's limitations (Excel followed the Lotus bug of erroneously assuming 1900 was a leap year, and Leap seconds are unrecognized)
    Enjoy!
    Message Edited by Jeff Bohrer on 08-06-2009 02:28 PM
    Jeff

  • Insert Date and Time doesn't update

    i am inserting a date and time in my numbers documents so that i know which paper copy is the most current. i do this by going to Insert pulldown and selecting Data and Time while in a Footer Cell.
    this data does not update upon re-opening the file and i end up printing multiple copies over weeks and months with simply the date that I inserted the Date and Time into the footer.
    is there a way to do this so that it updates?
    TIA

    As most of the times,
    this kind of question is answered in Numbers User Guide.
    When you insert a date_time value in a cell, you insert a fixed value.
    If you want a living one, you must insert a formula.
    =NOW()
    or
    =TODAY()
    would achieve your goal.
    Yvan KOENIG (VALLAURIS, France) dimanche 25 décembre 2011 21:40:50
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • How to get server date and time using java code

    Hi,
    I'm new to java. I have one doubt about getting date and time of the server. can anyone give some sample code to get that.
    thanks in regards
    Gopi.

    you need 2 things
    1. something on the application server which exposes the servers time/date
    2. something on the client which makes use of your time service
    for instance, you could write a ServerTimeServlet that clients can call to get the time according to the server. or, if you've got a database in the server, often database software will provide a Time procedure or similar that does this, so you can use a simple SQL query to get the latest time

  • How do I insert date and time in my DB?

    Hi!
    I 'm trying to make an application that the user enters some information (name, address...) and I also have a field where the user must enter date and time. But I don't know how to insert it to the database (MS Access). How can I convert a string into a date or time object in order to insert it to the db?
    I am new in programming with databases.
    Thanks in advance.

    Look at the following...
    java.sql.PreparedStatement (particularly the setDate, setTimestamp etc methods)
    and look at
    java.text.SimpleDateFormat

  • Can I print the date and time using aperture 4

    Work inspectors require that I provide pictures with date and time of creation from the metadata info.  I was looking at google searches and found Aperture with borderFX plug in might work.  Can anyone confirm this is a fact?  I would hate to pay for the software to find out this feature is not available during export.

    BorderFX and Aperture are a great combination for framing and annotating your finished photos. I like to second Frank Caggiano's answer.
    I am not sure from your post, if you already have Aperture, so just an add-on: BorderFX works also with iPhoto as an "Export" plug-in.
    You can access it in the "File > Export" panel, when saving a photo.
    If you do not own Aperture but iPhoto, you can try BorderFX first with iPhoto and see if it will suffice for your purposes. BorderFX is "Donation ware". You can try and explore it freely, before you donate. 
    BorderFX - iBorderFX iPhoto
    An Example:

  • How to get the system date and time using java

    hi,
    I want system date in my out put. how to access system date. can v use utill packaegs (or) sql. which one is the best to get.
    Thanks & Regards,
    Kenny.

    import java.util.Date;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    public class MyClass {
    public void setTimeStamp() {
    int hour, minute, second, time = 0;
    Date dt=new Date();
    System.out.println(dt.getDate());
    System.out.println(dt.getMonth());
    System.out.println(dt.getYear());
    Calendar cal = new GregorianCalendar();
    hour = cal.get(Calendar.HOUR_OF_DAY);
    minute = cal.get(Calendar.MINUTE);
    second = + cal.get(Calendar.SECOND);
    System.out.println (hour + ":" + minute + ":" + second);
    public static void main (String args[]){
    MyClass app = new MyClass();
    app.setTimeStamp();
    }

  • Problem with Inserting Date and Time in Oracle 8i

    I am using JDBC thin driver version 8.1.6. with oracle 8i and am unable to insert and update date & time in American format
    (mm/dd/yyyy hh24:mi:ss).
    example:
    UPDATE TABLE_NAME SET DATE_COLUMN='08/16/2000 12:45:00';
    Can someone please help?
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Kanwal:
    I am using JDBC thin driver version 8.1.6. with oracle 8i and am unable to insert and update date & time in American format
    (mm/dd/yyyy hh24:mi:ss).
    example:
    UPDATE TABLE_NAME SET DATE_COLUMN='08/16/2000 12:45:00';
    Can someone please help?
    <HR></BLOCKQUOTE>
    Hey Kanwal,
    You can try the following statement
    UPDATE TABLE_NAME SET DATE_COLUMN = to_date('08/16/2000 12:45:00','mm/dd/yyyy HH:MI:SS'
    WHERE .... ;
    null

  • Doubt in inserting Date and time into the table

    Hi i have created a table with two columns "Order_ID" and "Order_date" as
    create table test
    order_id integer,
    order_date date default sysdate
    Now i insert one row as
    insert into test(order_id) values(1);
    now i get the output as
    ORDER_ID ORDER_DAT
    1 05-JUN-12
    But i need to insert the current system time also into the Order_date column.
    How can i achieve this ???

    it works OK for me!
    bcm@bcm-laptop:~$ sqlplus user2/user2
    SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 4 20:19:57 2012
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    20:19:58 SQL> @test1
    20:20:01 SQL> create table test1
    20:20:01   2  (
    20:20:01   3  order_id integer,
    20:20:01   4  order_date date default sysdate
    20:20:01   5  );
    Table created.
    20:20:01 SQL>
    20:20:01 SQL> insert into test1(order_id) values(1);
    1 row created.
    20:20:01 SQL> select * from test1;
      ORDER_ID ORDER_DATE
          1 2012-06-04 20:20:01
    20:20:01 SQL>

Maybe you are looking for