How to insert the sysdate time into the database

hi all,
when i execute the following query,
insert into table_name
(date_field)
values
(to_date(sysdate, 'yyyy/mm/dd hh24:mi:ss'));
The value is inserted as 08-02-12 12:00:00. In this query, it always stores the default time as 12 a.m.
But i need to insert the original system time not the default one.
please help me how to rectify it.

I do not understand as to why you are using the to_date function on sysdate since sysdate is already in date format.
If date_field is of the data type date, then the following dml should work.
insert into table_name(date_field) values (sysdate);
In case date_field is a varchar2 field and you want to store the date and time in a string format, then the following statement should work.
insert into table_name (date_field)
values (to_char(sysdate, 'yyyy/mm/dd hh24:mi:ss'));

Similar Messages

  • How to insert a image file into oracle database

    hi all
    can anyone guide me how to insert a image file into oracle database now
    i have created table using
    create table imagestore(image blob);
    but when inserting i totally lost don't know what to do how to write query to insert image file

    Hi I don't have time to explain really, I did have to do this a while ago though so I will post a code snippet. This is using the commons file upload framework.
    Firstly you need a multi part form data (if you are using a web page). If you are not using a web page ignore this bit.
    out.println("<form name=\"imgFrm\" method=\"post\" enctype=\"multipart/form-data\" action=\"FileUploadServlet?thisPageAction=reloaded\" onSubmit=\"return submitForm();\"><input type=\"FILE\" name=\"imgSource\" size='60' class='smalltext' onKeyPress='return stopUserInput();' onKeyUp='stopUserInput();' onKeyDown='stopUserInput();' onMouseDown='noMouseDown(event);'>");
    out.println("   <input type='submit' name='submit' value='Submit' class='smalltext'>");
    out.println("</form>"); Import this once you have the jar file:
    import org.apache.commons.fileupload.*;Now a method I wrote to upload the file. I am not saying that this is correct, or its the best way to do this. I am just saying it works for me.
    private boolean uploadFile(HttpServletRequest request, HttpSession session) throws Exception {
            boolean result = true;
            String fileName = null;
            byte fileData[] = null;
            String fileUploadError = null;
            String imageType = "";
            String error = "";
            DiskFileUpload fb = new DiskFileUpload();
            List fileItems = fb.parseRequest(request);
            Iterator it = fileItems.iterator();
            while(it.hasNext()){
                FileItem fileItem = (FileItem)it.next();
                if (!fileItem.isFormField()) {
                    fileName = fileItem.getName();
                    fileData = fileItem.get();
                    // Get the imageType from the filename extension
                    if (fileName != null) {
                        int dotPos = fileName.indexOf('.');
                        if (dotPos >= 0 && dotPos != fileName.length()-1) {
                            imageType = fileName.substring(dotPos+1).toLowerCase();
                            if (imageType.equals("jpg")) {
                                imageType = "jpeg";
            String filePath = request.getParameter("FILE_PATH");
            session.setAttribute("filePath", filePath);
            session.setAttribute("fileData", fileData);
            session.setAttribute("fileName", fileName);
            session.setAttribute("imageType", imageType);
            return result;  
         } And now finally the method to actually write the file to the database:
    private int writeImageFile(byte[] fileData, String fileName, String imageType, String mode, Integer signatureIDIn, HttpServletRequest request) throws Exception {
            //If the previous code found a file that can be uploaded then
            //save it into the database via a pstmt
            String sql = "";
            UtilDBquery udbq = getUser(request).connectToDatabase();
            Connection con = null;
            int signatureID = 0;
            PreparedStatement pstmt = null;
            try {
                udbq.setUsePreparedStatements(true);
                con = udbq.getPooledConnection();
                con.setAutoCommit(false);
                if((!mode.equals("U")) || (mode.equals("U") && signatureIDIn == 0)) {
                    sql = "SELECT SEQ_SIGNATURE_ID.nextval FROM DUAL";
                    pstmt = con.prepareStatement(sql);
                    ResultSet rs = pstmt.executeQuery();
                    while(rs.next()) {
                       signatureID = rs.getInt(1);
                    if (fileName != null && imageType != null) {
                        sql = "INSERT INTO T_SIGNATURE (SIGNATURE_ID, SIGNATURE) values (?,?)";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setInt(1, signatureID);
                        pstmt.setBinaryStream(2, is2, (int)(fileData.length));
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
                if(mode.equals("U") && signatureIDIn != 0) {
                    signatureID = signatureIDIn.intValue();
                    if (fileName != null && imageType != null) {
                        sql = "UPDATE T_SIGNATURE SET SIGNATURE = ? WHERE SIGNATURE_ID = ?";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setBinaryStream(1, is2, (int)(fileData.length));
                        pstmt.setInt(2, signatureID);
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
            } catch (Exception e) {
                con = null;
                throw new Exception(e.toString());
            return signatureID;
       }

  • How to insert application form id into the form template

    Hi,
    Is there a way to set the application form id into a form template designed from the LiveCycle Designer? Here is the detail description of my question:
    (1) I am using LiveCycle Design to design a form template.
    (2) I go to our application to deploy this form template. During the process, a form id will be generated and it will be associated with this form template.
    (3) I would like to insert this generated form id into the form template, so that later when user fills out and submits the form, I will know what's the form id the submitted data belongs to.
    Appreciate you kind help!!!

    Hi Justin,
    Yes. The form ID will be generated by our application during the form deployment process (after the form is designed, it needs to be deployed to our application before it can be used.). So I was hoping there is a way to set the form ID into the form template design at that point. So that later when end user fills out and submits this form, I will know what form ID it is related to.
    If I cannot do this at the deployment point, one way I can think of is to do it at the time when end user is downloading the form. I can return a "rendered" form (instead of opening up the form template directly) with the form ID information in it. But that means for every single form user opened we need to render it at run time to fill in the form ID, which is not performing and what I was trying to avoid.
    Thanks for your help!
    Anita

  • 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>

  • urgent insert Date with Time into Access Database

    i found the following codes from the forum to insert date into microsoft access database:
    java.sql.Date date = new java.sql.Date((new java.util.Date()).getTime())
    stmt.executeUpdate("INSERT INTO Testing " +"VALUES (#"+date+"#)");
    but i need to insert the date together with its time so may i know how can i do it?

    thanks alot i works... but it allow only one value to be inserted.
    so i try the codes below:
    Timestamp ts=new Timestamp(tryDate.getTime());
    PreparedStatement p = connection.prepareStatement("insert into testing values(?,?)");
    p.setTimestamp(1,ts);
    p.setString(2,theMsg.getContent());
    p.executeUpdate();
    and error is this:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Number of query values and destination fields are not the same.
         at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106)
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:2564)
         at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedStatement.java:214)
         at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(JdbcOdbcPreparedStatement.java:136)
         at DBIncomingQueue.insertMessage(DBIncomingQueue.java:84)
         at DBIncomingQueue.main(DBIncomingQueue.java:213)

  • How to insert a 2D array into the end of X axis of the initial array?

    Hi, friends, I have a question and look for an advice. I have several input data, each of which has 4 rows and unknow columns. Each time I receive the input, I need to combine it to all of the previous ones by adding it to the end of X axis of the previous combined data. I must do it because, later, I need to run my model and my model read input for each column of 4 rows. How should I do it? Also, should I initiate an array before reading all of the inputs? The inputs are F32 format. Thank you very much for any of your advice.

    Building a 2D array row-by-row is easy. You either use "build array" if you need to update the indicator during the run, or you simply autoindex at the loop  boundary (FOR or WHILE).
    Two possibilities are shown in the attached image. If your arrays are getting large and you use a while loop, there are possibilities that are more memory efficient. You would initialize a 2D array (e.g. filled with NaNs) of an upper boundary of the final expected size, then replace rows as you go.
    (Notice that if you use autoindexing on a FOR loop, the final size is known from the beginning so memory can be allocated efficiently)
    Message Edited by altenbach on 11-01-2006 09:19 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    AppendRows.png ‏5 KB

  • How to insert drop-down box into the already set-up table ?

    if i have a table already set up, and i do want to add the drop-down box into each column like in the excel. how would i do that ? this drop-down box would allows me to specifically select the data as shown on the screen.

    Hi Bondwaan,
    I am not sure wht you are asking but I suspect it has to do with a popup menu. If that is the case, a popup menu is a formatting choice.
    If you need more info, you will need to ask a more specific question.
    quinn

  • Possible to insert a countdown timer into an iMovie clip?

    I'm making an exercise video, and I want to insert an occasional small clip with a countdown timer.  Ideally, it would be some beautiful nature footage (like waterfalls or wildlife), with a countdown timer in the corner.
    Does anydbody know how to insert a countdown timer into an iMovie clip?
    For that matter, does anybody know where I could find/purchase 2 minutes of nature footage?

    Sure you can. What you need to do is add the initial image to the topic then create an image map. This allows you to define shapes that when the user's mouse hovers over it indicates that there is a hyperlinkto another topic. Just right click on the image, select Insert Image Map and go from there.
      The RoboColum(n)
      @robocolumn
      Colum McAndrew

  • How to insert an image file in Oracle database

    hi
    can you please tell me how to insert an image file into oracle database????
    suppose there is one image file in c:\pictures\rose.jpg. how to insert that file into database? theoretically i know that will be BFILE type but i dont know how to insert that.
    will be waiting for your reply........
    thanks & regards,
    Priyatosh

    Hello,
    The easiest way to load a blob is to use SQL loader.
    This example comes from the utilities guide:
    LOAD DATA
    INFILE 'sample.dat'
    INTO TABLE person_table
    FIELDS TERMINATED BY ','
    (name CHAR(20),
    1 ext_fname FILLER CHAR(40),
    2 "RESUME" LOBFILE(ext_fname) TERMINATED BY EOF)
    Datafile (sample.dat)
    Johny Quest,jqresume.txt,
    Speed Racer,'/private/sracer/srresume.txt',
    Secondary Datafile (jqresume.txt)
    Johny Quest
    500 Oracle Parkway
    Secondary Datafile (srresume.txt)
    Loading LOBs
    10-18 Oracle Database Utilities
    Speed Racer
    400 Oracle Parkway
    regards,
    Ivo

  • How do I insert a video clip into the timeline?

    Do you happen to know how I could insert a video clip into the middle of a movie like you do in FCP? Can you add tracks and insert the clip above the spot i need to change for each movie.
    I don't want to render the whole movie (convert it into a MPeg2) each time.

    No - DVD timelines are a little different to FCP. If you need to add a clip to the stream, you need to split the exisitng clip (you could trim it back to where you want to insert the new piece) and drag the new piece onto the same timeline. If you trimmed the existing piece then add another instance of it to the timeline and trim the new part from the left until you get to what you want as the out point.
    If you have a collection of video clips on your DVDSP timeline, simply dragging a new one on will shuffle the others along appropriately. However, the audio will not shuffle with them, and you'll end up moving it all manually.
    The very best thing is to create the timeline precisely as you want it in FCP and encode it to MPEG2 before bringing it in to DVDSP. Remember that DVDSP is not an editor, it is a place to assemble your work - it won't do anything remotely like FCP in that respect.

  • I downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?

    i downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?

    hi philly, thanks for getting back to me, especially on such a busy day.
    I don't think that's quite the issue though. I bought an album and it appears in 'my purchases' within the itunes app. Yet, in order to listen to the music, i must use the 'music' app and in this application, there are only three tracks displayed at any one time from my downloaded album.
    I can 'download all' from the 'my purchases' section but that still doesn't help, it just keeps the last three tracks downloaded in the music app.
    I have the 'icloud' enabled and wondered if it had anything to do with that.
    i have successfully downloaded another full album totally into the music app, but this first album is causing me problems.

  • How can I save my data and the date,the time into the same file when I run this VI at different times?

    I use a translation stage for the experiment.For each user in the lab the stage position (to start an experiment) is different.I defined one end of the stage as zero. I want to save the position , date and time of the stage with respect to zero.I want all these in one file, nd everytime I run it it should save to the same file, like this:
    2/12/03 16:04 13567
    2/13/03 10:15 35678
    So I will track the position from day to day.If naybody helps, I appreciate it.Thanks.

    evolution wrote in message news:<[email protected]>...
    > How can I save my data and the date,the time into the same file when
    > I run this VI at different times?
    >
    > I use a translation stage for the experiment.For each user in the lab
    > the stage position (to start an experiment) is different.I defined one
    > end of the stage as zero. I want to save the position , date and time
    > of the stage with respect to zero.I want all these in one file, nd
    > everytime I run it it should save to the same file, like this:
    > 2/12/03 16:04 13567
    > 2/13/03 10:15 35678
    >
    > So I will track the position from day to day.If naybody helps, I
    > appreciate it.Thanks.
    Hi,
    I know the function "write to spreadsheet file.vi"
    can append the data
    to file. You can use the "concatenate strings" to display the date,
    time as well as data... Hope this help.
    Regards,
    celery

  • How can I set up lightroom 5 in my macbook, so that it becomes my default editing program, so that it starts up when I insert my sd card into the mac

    How can I set up lightroom 5, so that it becomes my main / default editing program & that when I insert my sd card into the mac lightroom starts instead of iPhoto .

    Thanks.  Im new to apple, which preference?
    Sent from my iPhone

  • TS1315 I have just purchased the new iPad with the camera connection kit. I just want to bewant to be able to insert my SD card into the Pad and only view my photos, not import them to the pad.  Can this be done and how do I do this.  Please advise.  Thaj

    I have just purchased the new iPad with the camera connection kit.  I just want to be able insert my SD card into the Pad and view my photos, not import them.Can this be done and how?  Please advise.  Thank you.

    See this article: iPad: Using the iPad Camera Connection Kit
    No, this canot be done, afaik. When your camera or card is connected, you will see the thumbnails in the camera pane, but not full size preview. So to browse your photos on the iPad you will need to import them to your camera roll. But you need not delete them from the camera or card after importing, so you might simply import selected photos to your camera roll from the camera grid and then delete them again from the camera roll after importing and browsing, without removing them from the card/camera.
    Regards
    Léonie

  • How do I get my file into the time line in Premiere Pro CC?

    How do I get my file into the time line in Premiere Pro CC? I am use to Premier Pro CS6 and unfortunately my labtop took a crash and I lost all of my adobe products. I wanted to check out a trial version and I cannot seem to find one for CS6! Please Help Me! My project is due tonight!!!!!

    Hi Aneumann,
    Welcome to the Forums.
    You have to just right click on the clip imported, in the project panel and select new sequence from clip. You can also go to file menu>new>sequence and create a sequence and then drag the clips after importing them , into the timeline.
    Regards,
    Vinay

Maybe you are looking for

  • Why does final cut pro x dvd burn take so much time?

    I have been trying to nurn a DVD and upload to YOUTUBE with Final Cut Pro X .......I have done this with ease many times before but now a 6 minute video is taking 3 hours to load fpr a DVD burn and ove 2 hours for YOUTUBE upload.. I have the energy s

  • Problem in writing Hindi Font in properties file at run time.!

    hi, We are using Language translator for our project. We are able to convert the language in hindi and chinese language. Im also creating properties file respective to each page in hindi,english and chinese language. At run time while CREATING proper

  • IDM Implementation issue

    current design: There are 5 applications running on weblogic 10 which needs to be integrated with IDM. for this I have installed sim/sam on sun application server and there is reverse proxy instace for each application and J2ee policy agent on each a

  • Interactive report - unable to disable save report option

    Hi, I am using an interactive report and unable to disable "Save Report" option... Although the option is unchecked under "Include in Actions Menu" section... Others' are working fine, I just can't disable "Save Report" option... Thanks in advance...

  • Remove battery while using power adapter?

    I mostly use my Macbook running on the power adapter and was told that this would kill the battery if left in the laptop. Is this true?