Timestamp field in Oracle

I have an application to log some data into my Oracle via ODBC. There's a field called 'timestamp' which is generated automatically by my logging application.
In Oracle, if I do a 'SELECT', it reads 07-MAY-04, but if I import all the data to Access, it reads like this: 5/7/2004 3:08:00 PM.
I want to be able to select a range data based on time. For example, I want to select everything that is within 5/7/2004 1:00:00 PM to 5/7/2004 4:00:00 PM, how do I write my SQL query?

I assume, first of all, that the column named "timestamp" is of type DATE, not of type TIMESTAMP.
In Oracle, a date always contains a date and a time component. The default date format, however, omits the time part of the date when it comes time to display it. You can alter that behavior by using an explicit to_char cast or by altering your NLS_DATE_FORMAT
SELECT to_char( timestamp, 'DD-MON-YYYY HH24:MI:SS' )
  FROM <<your table>>or
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
SELECT timestamp
  FROM <<your table>>When you want to SELECT data, you will want to use the to_date cast to convert a string to a date for comparison, i.e.
SELECT *
  FROM <<your table>>
WHERE timestamp BETWEEN to_date( '5/7/2004 13', 'MM/DD/YYYY HH24' )
                     AND to_date( '5/7/2004 16', 'MM/DD/YYYY HH24' );Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • CMP 2 non mandatory timestamp field in Oracle 9 release 2

    Dears,
    My machine holds the following:
    Win XP pro SP 1
    Oracle 9i release 2 DB
    Jbuilder X enterprise Edition with SUN ONE App Server plugin
    SUN ONE Application server platform edition update 2
    They are all in the same machine (so there is no problem as issue 4707531 of using different Oracle drivers)
    I connect using OCI not thin.
    I got the following problem when trying to test my Session EJB that calls CMP.
    SEVERE ( 4716): EJB5071: Some remote or transactional roll back exception occurredcom.sun.jdo.api.persistence.support.JDODataStoreException: Got a JDBC SQLException.
    Please read the remaining error stack for more information.
    NestedException: java.sql.SQLException: Invalid column typeBy tracing the problem I noticed that my code works fine if I set a timestamp field in this table, this timestamp is not mandatory.
    Is it a bug in SUN ONE with Oracle 9i, or anyone have a solution?

    Hi Ash,
    Could you please verify that your .dbschmea file and table creation scripts are in sync. The easiest way to achieve this is to recapture the .dbschema file, repackage and redeploy.
    Thanks,
    Mitesh

  • Error when reading BLOB field from Oracle usin Toplink

    We experience a very annoying problem when trying to read a BLOB
    field from Oracle 8.1.6.2.0 using TOPLink 3.6.3. I have attached the
    exception stack trace that is reported to the console. As far as I can
    judge a fault at oracle.sql.LobPlsqlUtil.plsql_length() happens first and
    then at TOPLink.Private.DatabaseAccess.DatabasePlatform.convertObject().
    The exception is permanently repeating that is very critical for us.
    ServerSession(929808)--Connection(5625701)--SELECT LOBBODY, ID, LABEL, FK_OBJECT_ID, FK_OBJECTTYPE FROM NOTE WHERE (ID = 80020)
    INTERNAL EXCEPTION STACK:
    java.lang.NullPointerException
    at oracle.sql.LobPlsqlUtil.plsql_length(LobPlsqlUtil.java:936)
    at oracle.sql.LobPlsqlUtil.plsql_length(LobPlsqlUtil.java:102)
    at oracle.jdbc.dbaccess.DBAccess.lobLength(DBAccess.java:709)
    at oracle.sql.LobDBAccessImpl.length(LobDBAccessImpl.java:58)
    at oracle.sql.BLOB.length(BLOB.java:71)
    at TOPLink.Private.Helper.ConversionManager.convertObjectToByteArray(ConversionManager.java:309)
    at TOPLink.Private.Helper.ConversionManager.convertObject(ConversionManager.java:166)
    at TOPLink.Private.DatabaseAccess.DatabasePlatform.convertObject(DatabasePlatform.java:594)
    at TOPLink.Public.Mappings.SerializedObjectMapping.getAttributeValue(SerializedObjectMapping.java:43)
    at TOPLink.Public.Mappings.DirectToFieldMapping.valueFromRow(DirectToFieldMapping.java:490)
    at TOPLink.Public.Mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:808)
    at TOPLink.Private.Descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:173)
    at TOPLink.Private.Descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:325)
    at TOPLink.Private.Descriptors.ObjectBuilder.buildObjectsInto(ObjectBuilder.java:373)
    at TOPLink.Public.QueryFramework.ReadAllQuery.execute(ReadAllQuery.java:366)
    at TOPLink.Public.QueryFramework.DatabaseQuery.execute(DatabaseQuery.java:406)
    I have started the application with Oracle JDBC logging on and found that the problem may originate in a possible lack of syncronization in the pooled connection implementation:
    DRVR FUNC OracleConnection.isClosed() returned false
    DRVR OPER OracleConnection.close()
    DRVR FUNC OracleConnection.prepareCall(sql)
    DRVR DBG1 SQL: "begin ? := dbms_lob.getLength (?); end;"
    DRVR FUNC DBError.throwSqlException(errNum=73, obj=null)
    DRVR FUNC DBError.findMessage(errNum=73, obj=null)
    DRVR FUNC DBError.throwSqlException(reason="Logical handle no longer valid",
    SQLState=null, vendorCode=17073)
    DRVR OPER OracleConnection.close()
    so the prepareCall() is issued against an already closed connection and the
    call fails.
    I assume we have been using a JDBC 2.0 compliant driver. We tried out
    drivers that Oracle supplies for 8.1.6, 8.1.7 versions. To be true I
    couldn't find any information about the JDBC specification they conform to. Does it
    mean that these drivers may not be 100%-compatible with JDBC 2.0 Spec?
    How can I find out if they are 2.0 compliant?
    Also I have downloaded Oracle 9.2.0.1 JDBC drivers. This seemed to work
    fine until we found another incompatibility which made us return back to
    8.1.7 driver:
    UnitOfWork(7818028)--Connection(4434104)--INSERT INTO STATUSHISTORY (CHANGEDATE, FK_SET_STATUS_ID) VALUES ({ts '2002-10-17 16:46:54.529'}, 2)
    INTERNAL EXCEPTION STACK:
    java.sql.SQLException: ORA-00904: invalid column name
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.jav
    a:2047)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java
    :1940)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatemen
    t.java:2709)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePrepare
    dStatement.java:589)
    at TOPLink.Private.DatabaseAccess.DatabaseAccessor.executeDirectNoSelect(
    DatabaseAccessor.java:906)
    at TOPLink.Private.DatabaseAccess.DatabaseAccessor.executeNoSelect(Databa
    seAccessor.java:960)
    at TOPLink.Private.DatabaseAccess.DatabaseAccessor.executeCall(DatabaseAc
    cessor.java:819)
    at TOPLink.Public.PublicInterface.UnitOfWork.executeCall(UnitOfWork.java:

    Hello Yury,
    I believe the problem is that TopLink's ServerSession by default executes read queries concurrently on the same connection. It does this to reduce the number of required connections for the read connection pool. Normally this is a good concurrency optimization, however some JDBC drivers have issues when this is done. I had thought that with Oracle JDBC 8.1.7 this issue no longer occurred, but perhaps it is only after version 9. I believe that the errors were only with the thin JDBC driver, not the OCI, so using the OCI driver should also resolve the problem. Using RAW instead of BLOB would also work.
    You can configure TopLink to resolve this problem through using exclusive read connection pooling.
    Example:
    serverSession.useExclusiveReadConnectionPool(int minNumerOfConnections, int maxNumerOfConnections);
    This will ensure that TopLink does not to try to concurrently execute read queries on the same connection.
    I'm not exactly sure what your second problem with the 9.x JDBC drivers is. From the SQL and stack trace it would seem that the driver does not like the JDBC timestamp syntax. You can have TopLink print timestamp in Oracle's native SQL format to resolve this problem.
    Example:
    serverSessoin.getLogin().useNativeSQL();
    Make sure you configure your server session before you login, or if using the TopLink Session Manager perform the customizations through a SessionEventListener-preLogin event.

  • Working with TIMESTAMP fields in Excel

    Please forgive me if this is a really stupid question.
    I have an Oracle 10g dtabase that i am trying to connect to via ODBC in Excel.
    I can get data from tables into MS Query untill i try and insert a TIMESTAMP field when all fails. The TIMESTAMP field ahave a time zone on them.
    Can anyone point me in the direction of an ODBC driver which works in this situation, i have tried the standard MS driver and also the ODBC driver supplied by ORACLE.
    Thanks in advance for any help.

    It would be interesting to know your ODBC driver version.
    Basic TIMESTAMP is supposed to be supported but TIMESTAMP WITH TIME ZONE,
    TIMESTAMP WITH LOCAL TIME ZONE are not supported.
    Do you get the error ORA-932 inconsistant datatypes or another error when you select your Oracle table?
    So far as I remember, you can download the ODBC driver from DataDirect :
    http://www.datadirect.com/products/odbc/index.ssp
    The Datadirect driver seems to handle Timestamp with Time Zone.
    Please try with this one and let me know your feedback.
    Regards
    Mireille

  • Writing the value from an unbound Date picker field to a timestamp field.

    Hi,
    I am having a frustrating time trying to write the results of a date field to a Timestamp field in an oracle10 table in APEX 3.1. The Date Picker correctly returns 01-JUN-2008 23:59 into the date picker page item :P60_EXTENTION_DATE (As a varchar I believe).
    Using a plsql function similar to the following I am trying to write the date to a timestamp field eg.
    begin
    update customers set extention_date = :P60_EXTENTION_DATE where ROW_ID = 34;
    end;
    This without fail this gives me stupid errors it wants 2 digit years, it wants AM/PM.
    I have tried this:
    update customers set extention_date = to_date(:P60_EXTENTION_DATE) where ROW_ID = 34;
    and:
    update customers set extention_date = to_date(:P60_EXTENTION_DATE,'DD-MON-YYYY HH24:MI') where ROW_ID = 34;
    How can the date picker return a date that oracle "ORA-01821: date format not recognized" ? It just seems un-intuitive (fricken retarded) to me.
    I have tried about 30 combinations date picker, to_date formats etc. and it is driving me nuts, can someone please tell me which combination of date picker and to_date function I need to make this work.
    1 free internets to anyone who can help.
    Cheers
    Message was edited by:
    cl3ft typos

    Hello,
    >> …trying to write the results of a date field to a Timestamp field …
    can someone please tell me which combination of date picker and to_date function I need to make this work.
    If the target is a timestamp column, did you try to use the to_timestamp function? http://www.techonthenet.com/oracle/functions/to_timestamp.php .
    Regards,
    Arie.

  • How to encrypt the text in password field in Oracle Forms version 6i

    Need help!
    How to encrypt the text in password field in Oracle Forms version 6i?
    one way is to change the settings in the property palette. Can somebody provide me some script to be run while the form is running which will enable the password to be encrypted?
    Thanks!

    Hello,
    Do you mean "hidden" (replaced with stars) or encrypted (that needs to be decrypted ?
    Francois

  • Error while inserting the value in xmltype field of oracle using ALDSP?

    I am getting the following error, while trying to insert the large xml in the xmltype field of oracle using aldsp service:
    inconsistent datatypes: expected - got CLOB in bea
    But this error does not occur when the input xml is of smaller size.

    Please post the complete error message and stack trace.

  • How can I create an index on the date part of a timestamp field?

    is there a way I can create an index on the date part of a timestamp field?

    LONGENECKER wrote:
    Idea:
    If you find no direct command that allows you to create an index on JUST the date portion of a timestamp datatype column then I recommend you consider splitting date and time into two seperate columns.
    If date is column "A" and time is column "B" then you can concatenate them using a view or virtual column (in 11G) to re-assemble them at run time.
    In the solution I describe above you might trade ease of management for better performing queries.
    Additional Info:
    This thread may be of some value.
    Can we create INDEX on TIMESTAMP column???
    And what datatype do you propose for your columns A and B? The only proper datatypes would be DATE or TIMESTAMP. Both of these inherently carry both date and time components, so that would have to be dealt with anyway. The use of any character or number datatype to hold date and/or time should be treated with an application of Billy's lead pipe.
    Perhaps function based indexes would be a better solution.

  • Inserting to a CLOB field in Oracle 8i  Database

    Hi All,
    I am trying to insert a value to a CLOB field in Oracle 8i DB.
    The value gets inserted when the size is less (Up to around 80 Bytes).
    When the size becomes larger the insertion does not take place but no exception is thrown.
    Please see below the code I have written.
    PreparedStatement preparedStatement = null;
              try {
                   connection = getConnection(MMAKeys.WMDS_DATASOURCE);
                   String query = "UPDATE s_mmhp_batch SET MMHP_REPORT_CLOB=(?) WHERE MMHP_BATCH_ID=(?) AND MMHP_USER_ID=(?) AND MMHP_MEMBER_KEY=(?)";
              preparedStatement=connection.prepareStatement(query);
              Reader r = new StringReader(clobReport);
              preparedStatement.setCharacterStream(1, r, clobReport.length());
              oracle.sql.CLOB newClob = oracle.sql.CLOB.createTemporary(connection , false, oracle.sql.CLOB.DURATION_CALL);
              newClob.putString(1,clobReport);
              preparedStatement.setClob(1,newClob);
              preparedStatement.setInt(2,batchId);
              preparedStatement.setString(3,userId);
              preparedStatement.setString(4,memberKey);
              preparedStatement.executeUpdate();
              System.out.println("inside the write to Batch method after executing the query");
              } catch (SQLException exception) {
                   throw new DAOException(
                        "MREDMMSDAO -> writeToTable():SQLException"
                             + exception.getMessage());
              } catch (Exception exception) {
                   throw new DAOException(
                        "MREDMMSDAO -> writeToTable():Exception"
                             + exception.getMessage());
              } finally {
                   closeStatement(preparedStatement);
                   closeConnection(connection);
    I came to know that this method is not supported in Oracle 8i.
    I tried to create an empty CLOB and call the putValue() method.
    But Then, I got an exception stating that the method is not supported.
    Is there any other way to insert a CLOB value to Oracle 8i?
    Please help.
    Thanks in advance,
    Neelambary

    And cursor.callproc('insert_clob_proc', (clob,))
    doesn't work for you?
    PrzemekYes - I should have been more clear in my original post. The callproc function works until we have a value which is over 32K. At values over 32K, we get an error message "ORA-01460: unimplemented or unreasonable conversion requested". I believe this is because we are sending the value as a string and so we would need to figure out how to send as a CLOB in cx_Oracle? Here is some code to use to test if interested...
    Oracle (Oracle Database 10g Release 10.1.0.4.0 - Production):
    CREATE TABLE clob_test (CLOB_FIELD CLOB);
    CREATE OR REPLACE PROCEDURE ins_clob_test (v_clob_field IN CLOB)
    AS
    BEGIN
    INSERT INTO clob_test (clob_field) VALUES (v_clob_field);
    END ins_clob_test;
    Python (2.5):
    conn = cx_Oracle.connect(xhash['oraclelogin'])
    cursor = conn.cursor()
    clob_var = 'Some test data' * 10000
    cursor.callproc('ins_clob_test',(clob_var,))
    conn.commit()
    cursor.close()
    conn.close()
    I should also mention that I am the Oracle developer and not the Python programmer - my knowledge of Python is very limited. I would like the Python programmers to use the procedures (packages) I have created to do their inserts but this situation has caused them to put the SQL directly in their code.
    Thanks again for any assistance you can provide.
    Jason

  • Storing the Timestamp field in the Table

    Hi
    I have a Z program and we need to store the timestamp field in the Z table . I have created the table with the dataelement
    TIMESTAMP . Is there any system field that can be used to store the timestamp field from your program
    say for example we have declared a work area of the structure of the Z table and Appended through the Internal Table and Modified that Z table.
    My intention is store the Timestamp field in the Z table.
    Nadesh

    Hi,
        you can add as below..
    types : begin of st_output.
                             include structure ztaxinvoice.
                             FKIMG1 TYPE VBRP-FKIMG,
                             FKIMG2 TYPE VBRP-FKIMG,
                             types : end of st_output.
        or you can add this field to your structure 'ztaxinvoice'  as below
    'FKIMG1 TYPE FKIMG'
                                       'FKIMG2 TYPE FKIMG'
       Then you can declare internal table and work area as mentioned below..
    data: it_output type standard table of ztaxinvoice,
                            wa_output type ztaxinvoice.
    here in this case no need of types declaration also you can pass the same type (wa_output type ztaxinvoice) in smartform.
    hope this will help you,
    Regards,
    Renuka S.

  • How to increase the width of a field in oracle reports 6i

    Hello,
    I'm facing a problem related to width of field. I have a table with field abc varchar2(1500) and when I try to show it in report. I'm unable to see complete data because field size in report is 300.
    Kindly guide me to increase the size/width of field in oracle report 6i
    thanks in advance
    sadiq

    Post your question on Reports forum
    Reports

  • How could I Write data into a field in Oracle whose data type is VARCHAR2

    The target data I want to write into Oracle is in http://tw.yahoo.com/info/utos.html.
    Now, these data is stored in Mysql database and the field which stores these data uses "Text" as its data type.
    I want to derive these data from mysql database and store them into a field of oracle database.
    In oracle, I create field whose data type is varchar2(4000) to store these data.
    I use JSP to derive data from mysql and insert into oracle through JDBC.
    But the result of the page shows me that "javax.servlet.ServletException: Data size bigger than max size for this type: 25623".
    Please anyone could help to resolve this problem?
    Thank you very much.

    My hunch is that the problem is that VARCHAR2(4000), but default, allocates 4000 bytes of storage. Depending on your database character set, a single character may require up to 4 bytes of storage.
    If you are on 9i, you can declare the column VARCHAR2(4000 CHAR) to allocate 4000 characters of storage. You can also set NLS_LENGTH_SEMANTICS to CHAR, which will cause Oracle to assume that your declarations are in characters rather than bytes.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • XML Forms. Add a timestamp field

    Hi all
    I have a XML Forms project. I have included the valid from and valid until values and have tbs working.
    Appart from this I want to insert in my form another Timestamp field.
    In the datamodel I can´t create an entry of type timestamp, only date or time.
    If I create it date and bind it to a timestamp reaader object from the toolbar I receive an error requesting to have a timestamp type of data binded to it.
    Any help to do this?
    Let me know if you need more info.
    Regards
    Fernando

    Hi Kevin,
    there is no possibility to provide default values or vairable values for date and time properties in KM.
    The only thing you can specify is the format:
    <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/42/e646150fbc3ee6e10000000a1553f7/frameset.htm">http://help.sap.com/saphelp_nw2004s/helpdata/en/42/e646150fbc3ee6e10000000a1553f7/frameset.htm</a>
    One thing you could do is modify the xsl file and use some additional programming to fill the date whith the values you like.
    But in the standard it is not possible.
    Not only for XML forms, but in general for KM properties this is not possible...
    Regards,
    Sascha
    Regards,
    Sascha

  • Import Wizard with timestamp fields

    Hi there,
    I'm trying to copy data with time stamp from one server to another, but I'm keep getting the following error.
    Error 0xc0202048: Data Flow Task: Attempting insertion into the row version column "TimeStamp". Cannot insert into a row version column.
    (SQL Server Import and Export Wizard)
    Is there anyway I can deselect the timestamp field when I run the wizard?
    How can I successfully transfer the data?
    Thanks
    regards,
    Mike

    Hi, I'm having the same issue even with the On Error column set to 'ignore" in the Data Type Mapping review screen.
    I've also seen in the Conversion Details the comment about timestamp vs VarChar, but if I uncheck the Convert column I am unable to run the import.
    There must be a way to overcome this?
    Thanks
     Validating (Error)
    Messages
    Error 0xc0202048: Data Flow Task 1: Attempting insertion into the row version column "TimeStamp". Cannot insert into a row version column.
     (SQL Server Import and Export Wizard)
    Error 0xc0202045: Data Flow Task 1: Column metadata validation failed.
     (SQL Server Import and Export Wizard)
    Error 0xc004706b: Data Flow Task 1: "component "Destination - SorContractPrice" (92)" failed validation and returned validation status "VS_ISBROKEN".
     (SQL Server Import and Export Wizard)
    Error 0xc004700c: Data Flow Task 1: One or more component failed validation.
     (SQL Server Import and Export Wizard)
    Error 0xc0024107: Data Flow Task 1: There were errors during task validation.
     (SQL Server Import and Export Wizard)
    [Source Information]
    Source Location : E:\SYSPRO61\Temp\METSUPL.xls
    Source Provider : Microsoft.Jet.OLEDB.4.0
    Table: `METSUPL$`
    Column: TimeStamp
    Column Type: VarChar
    SSIS Type: Unicode string [DT_WSTR]
    Mapping file (to SSIS type): C:\Program Files (x86)\Microsoft SQL Server\100\DTS\MappingFiles\JetToSSIS.xml
    [Destination Information]
    Destination Location : siwerp
    Destination Provider : SQLNCLI10
    Table: [dbo].[SorContractPrice]
    Column: TimeStamp
    Column Type: timestamp
    SSIS Type: byte stream [DT_BYTES]
    Mapping file (to SSIS type): C:\Program Files (x86)\Microsoft SQL Server\100\DTS\MappingFiles\MSSQLToSSIS10.XML
    [Conversion Steps]
    Step 1: DT_WSTR to DT_BYTES
    SSIS conversion file: C:\Program Files (x86)\Microsoft SQL Server\100\DTS\binn\DtwTypeConversion.xml

  • Adding a timestamp field to a table (MySQL database)

    I've defined a field in a MySQL table as type 'timestamp'
    eg. 2010-05-25 21:36:19
    When I perform an insert using coldfusion, the row doesn't change the value in the timestamp automatically
    Am I better creating my own timestamp field, type varchar and manually insert my timestamp values ?

    No, it is a pretty bad idea to use a text field to store date-time information.  It makes it much harder to do date and|or time calculations on the data.
    A timestamp field does not mean you have a field that automatically inserts a timestamp on record insert and|or update.  Just that you have a field that expects a 'timestamp' value which is usually a date-time value down to the millisecond precision.
    You can set up the database to automatically create this value when data is inserted and|or updated, but that is more then just creating the timestamp field.  And the specifics will change depending on your exact database management system.  Searching the internets for information on your database managerment system of choice and auto and|or default values for fields should guide you in the correct direction.
    Or you can insert timestamp data along with the other data you are inputting into the database.  The now() function combined with the <cfqueryparam value="#timeData#" cfsqltype="cf_sql_timestamp"> is a useful combination to do this.

Maybe you are looking for