Unix timestamp to Oracle timestamp conversion

Hi all,
I am trying to convert the UNIX timestamp to ORACLE timestamp .
I have done like this upto now.
CREATE OR REPLCACE FUNCTION unixts_to_oraclets(unixtimestamp IN INTEGER)
RETURN DATE IS
result DATE;
BEGIN
result := TO_DATE('1970-01-01', 'YYYY-MM-DD') + numtodsinterval(unixtimestamp, 'SECOND');
return(result);
end unixts_to_oraclets;
now i have run this query
SQL> select unixts_to_oraclets(1139291114) as TS from dual;
TS
07-FEB-06
now i need the ouput to like this 07-FEB-06 01:10:12
for that i have done like this:
DECLARE
v_date DATE;
res_date DATE;
BEGIN
SELECT from_uts(1139291114)INTO v_date FROM dual;
SELECT TO_TIMESTAMP(v_date,'DD-MON-RRHH24.MI.SS.FF') INTO res_date FROM dual;
DBMS_OUTPUT.PUT_LINE(res_date);
END;
but the output is :
SQL> /
07-FEB-06
PL/SQL procedure successfully completed.
why is that it is not printing 07-FEB-06 01:10:12 ?
how should i moodify the code to get the desired output.
please help me i this regard
Trinath Somanchi,
Hyderabad.

SQL> exec dbms_output.put_line(sysdate);
07-FEB-06
PL/SQL procedure successfully completed.
SQL> exec dbms_output.put_line(to_char(sysdate, 'DD-MM-YYYY HH24:MI:SS'));
07-02-2006 02:48:35
PL/SQL procedure successfully completed.
SQL> alter session set nls_date_format='DD-MM-YYYY HH24:MI:SS';
Session altered.
SQL> exec dbms_output.put_line(sysdate);
07-02-2006 02:49:03
PL/SQL procedure successfully completed.

Similar Messages

  • DB2 timestamp to oracle timestamp conversion

    Does any one know how to convert Db2 timestamp into oracle timestamp.
    From DB2 we are getting timestamp in this format (2000-03-06-16.02.19.074474) (26 bytes).
    I want to insert this into oracle thru owb into oracle table with column type timestamp.
    Does anyone know the procedure for this type of conversion
    Thanks in advance..

    Hi,
    Try a migration tool at www.ispirer.com/chyfo.html
    It provides you the fastest, the easiest and the most powerful way to migrate
    DB2 database into Oracle.
    It works in conjunction with Oracle SQL Loader. The tool creates text files (moving of LOBs are fully supported), generates
    CREATE TABLE scripts for Oracle and control files for SQL Loader.
    The tool has a lot of other features.
    Best regards, Dmitry.
    null

  • Converting Oracle TIMESTAMP(4) column to SQL datetime column conversion error in ssis

    I could not able to convert Oracle TIMESTAMP(4) column to SQL datetime column conversion error in ssis.
    I'm connecting OLEDD Oracle Source to OLEDB SQL Destination in SSIS package. I'm trying to insert data from oracle datetime column into sql datetime column. I'm getting some errors.
    Please provide helpful info.

    You can transform the data types directly at the source by writing a proper SQL statement, or you can convert them using the data conversion component.
    Please refer the below link
    http://stackoverflow.com/questions/6256168/how-to-convert-a-timestamp-in-string-format-to-datetime-data-type-within-a-packa

  • 10g Oracle Timestamp conversion to milliseconds

    Hello!
    I'm sure this is possible and I have found a couple of references but none that work.
    How can I take an Oracle Timestamp and convert it using a SELECT statement into milliseconds?
    Thanks in advance

    It looked interesting but I don't think it is the answer.
    Isn't the Oracle timestamp based on the elapsed seconds since some date in 1970 or something? It seems there should be an algorithm to convert but I just haven't found it.

  • ORACLE TIMESTAMP DataType support in Toplink ?

    Currently we have an application that need to create timestamps with precision up to thousands of a second.
    Do you know of any other customer that have similar requirements and how they solve this problem ?
    We try changing the SQL DDL to change datatype from DATE to TIMESTAMP(3) which can support a timestamp of 1/1000 seconds precision.
    We find that if our Oracle column is defined as Oracle DATE, the last 3 digit will be drop and cause us some duplicate key exception for records that
    Get inserted within 1 second because the timestamp is part of the primary key.
    ts '2004-03-12 17:13:27.792'
    So we change the ORACLE column from DATE to TIMESTAMP(3)
    What we find is that Toplink produce this exception
    Exception [TOPLINK-3001] (OracleAS TopLink - 10g (9.0.4) (Build 031126)): oracle.toplink.exceptions.ConversionException
    Exception Description: The object [oracle.sql.TIMESTAMP@321b5e39], of class [class oracle.sql.TIMESTAMP], could not be converted to [class java.util.Date].
    at oracle.toplink.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:35)
    at oracle.toplink.internal.helper.ConversionManager.convertObjectToUtilDate(ConversionManager.java:679)
    at oracle.toplink.internal.helper.ConversionManager.convertObject(ConversionManager.java:97)
    at oracle.toplink.internal.databaseaccess.DatabasePlatform.convertObject(DatabasePlatform.java:55
    Than we try to change our java code and modify the java instance variable type from java.util.Date to java.sql.Timestamp
    And we get the following error
    Exception [TOPLINK-3001] (OracleAS TopLink - 10g (9.0.4) (Build 031126)): oracle.toplink.exceptions.ConversionException
    Exception Description: The object [oracle.sql.TIMESTAMP@731de027], of class [class oracle.sql.TIMESTAMP], could not be converted to [class java.sql.Timestamp].
    at org.apache.xerces.impl.XMLNamespaceBinder.endElement(XMLNamespaceBinder.java:650)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1011)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1564)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:335)
    We cannot seems to find in toplink mapping workbench how to specify timestamp
    ========================================================================================================
    The TIMESTAMP Datatype
    The new TIMESTAMP datatype is almost identical to DATE and differs in only one way:
    TIMESTAMPs can represent fractional seconds.
    The granularity of a TIMESTAMP value can be as little as a billionth of a second, whereas
    DATE variables can only resolve time to the second.
    When you declare a TIMESTAMP variable, you can optionally specify the precision that you wish to use for fractional seconds. The default precision is to the millisecond (six decimal digits); the maximum precision is to the billionth of a second (nine decimal digits).
    ===========================================================================================================
    -----Original Message-----
    From: Cheung, Ka-Kit
    Sent: Friday, March 12, 2004 6:20 PM
    To: Burr, Tim; Julian, Robert; Matthiesen, Sean
    Cc: Tsounis, George; Del Rosso, Peter; Cham, Mei
    Subject: Problem identified : AddressDetail duplicate key problem
    If we look at the exact of the insert statement.
    We see that the last address detail insert have key of
    Address ID = '5a052407-dac6-42ad-bbbf-29edc94488c1', and
    TransactionStartDate = {ts '2004-03-12 17:13:27.792'},
    While in the database, we look like we have an entry of
    Address ID = '5a052407-dac6-42ad-bbbf-29edc94488c1', and
    TransactionStartDate = {ts '2004-03-12 17:13:27.229'},
    If my memory served me right, while
    {ts '2004-03-12 17:13:27.792'}, is different than {ts '2004-03-12 17:13:27.229'},
    because are Java timestamps that have precison up to MicroSeconds, therefore 229 is different than 792.
    However, when this timestamp is saved to Oracle, I believe (have to check with Mei) that oracle only takes
    Up to '2004-03-12 17:13:27’ and discard the 229 or 792 because that is the maximum precision of timestamp for oracle.
    So we have the second insert have the same '2004-03-12 17:13:27’ after stripping off the 792 and we have a same record with the same same '2004-03-12 17:13:27’ in the database and
    Therefore causing duplicate key exception.
    That is why this is happen only once in a while when 2 rapid fire inserts happen in less than 1 second of each other.
    The solution actually is in the ESS code itselfs.
    The current ESS code will send addDependentToClient multiple times, one for each dependent added
    On the screen.
    The right way is to add all the dependent on the screen all at once.
    To have “course grain” method like addDependentsToClient, and have a collection or array of dependents as input parameter.
    This way we are not causing the participant to create history of themselves multiple times within a very short period of time. It save disk space, conform to a single UOW per submit and that is what I proposed
    To solve this problem from the root cause is by enhancing the method to save multiple dependents in one shot rather than a loop of multiple calls.
    KK
    and
    INSERT INTO PTTCBSI.ADDRESS_DETAIL
    (LINE_3_AD, ADR_TRAN_UNTIL_DT, MODIFY_DT, CITY_NM, POSTAL_CD, VER_ID, POSTAL_EXT_CD, LINE_2_AD, ADR_TRAN_START_DT, CREATE_DT, AUTHOR_ID, ADDRESS_ID, LINE_1_AD, COUNTY_NM, LINE_4_AD, COUNTRY_ID, STATE_ID)
    VALUES ('Block 5, Apt. 6', {ts '9999-12-31 00:00:00.0'},
    {ts '2004-03-12 17:13:26.385'},
    'Oakwood', '61043', 1, '1234', 'Mailstop 820',
    {ts '2004-03-12 17:13:26.385'},
    {ts '2004-03-12 16:50:12.0'}, 'dataLoad',
    '5a052407-dac6-42ad-bbbf-29edc94488c1',
    'IBM Corp.', NULL, '140 Main Street', 'US', 'NJ')
    UnitOfWork(1238222885)--Connection(2102560837)--
    UPDATE PTTCBSI.ADDRESS_DETAIL
    SET ADR_TRAN_UNTIL_DT = {ts '2004-03-12 17:13:26.385'}, VER_ID = 2 WHERE
    (((ADDRESS_ID = '5a052407-dac6-42ad-bbbf-29edc94488c1') AND
    (ADR_TRAN_START_DT = {ts '2004-03-12 16:52:29.0'})) AND (VER_ID = 1))
    UPDATE PTTCBSI.ADDRESS_DETAIL SET
    ADR_TRAN_UNTIL_DT = {ts '2004-03-12 17:13:27.229'}, VER_ID = 2
    WHERE (((ADDRESS_ID = '5a052407-dac6-42ad-bbbf-29edc94488c1') AND (ADR_TRAN_START_DT = {ts '2004-03-12 17:13:26.0'})) AND (VER_ID = 1))
    UnitOfWork(102762535)--Connection(2102560837)--
    INSERT INTO PTTCBSI.ADDRESS_DETAIL
    (LINE_3_AD, ADR_TRAN_UNTIL_DT, MODIFY_DT, CITY_NM, POSTAL_CD, VER_ID, POSTAL_EXT_CD, LINE_2_AD, ADR_TRAN_START_DT, CREATE_DT, AUTHOR_ID, ADDRESS_ID, LINE_1_AD, COUNTY_NM, LINE_4_AD, COUNTRY_ID, STATE_ID) VALUES
    ('Block 5, Apt. 6', {ts '9999-12-31 00:00:00.0'}, {ts '2004-03-12 17:13:27.229'}, 'Oakwood', '61043', 1, '1234', 'Mailstop 820',
    {ts '2004-03-12 17:13:27.229'},
    {ts '2004-03-12 16:50:12.0'}, 'dataLoad',
    '5a052407-dac6-42ad-bbbf-29edc94488c1',
    'IBM Corp.', NULL, '140 Main Street', 'US', 'NJ')
    INSERT INTO PTTCBSI.ADDRESS_DETAIL
    (LINE_3_AD,
    ADR_TRAN_UNTIL_DT,
    MODIFY_DT,
    CITY_NM, POSTAL_CD, VER_ID, POSTAL_EXT_CD, LINE_2_AD,
    ADR_TRAN_START_DT,
    CREATE_DT,
    AUTHOR_ID,
    ADDRESS_ID,
    LINE_1_AD, COUNTY_NM, LINE_4_AD, COUNTRY_ID, STATE_ID) VALUES
    ('Block 5, Apt. 6', {ts '9999-12-31 00:00:00.0'},
    {ts '2004-03-12 17:13:27.792'},
    'Oakwood', '61043', 1, '1234',
    'Mailstop 820',
    {ts '2004-03-12 17:13:27.792'},
    {ts '2004-03-12 16:50:12.0'},
    'dataLoad',
    '5a052407-dac6-42ad-bbbf-29edc94488c1',
    'IBM Corp.', NULL, '140 Main Street', 'US', 'NJ')
    ClientSession(790235177)--Connection(2102560837)--rollback transaction
    ORA-00001: unique constraint (PTTCBSI.PK_ADDRESS_DETAIL) violated

    KK,
    We are back-porting the support for oracle.sql.TIMESTAMP to 9.0.4 in an upcoming patch-set. It is possible to enhance TopLink using a customer conversion manager or database platform to add this support if required in the short term.
    Doug

  • Timestamp in oracle 8i

    Hi,
    Can anybody tell me, how can I implement Timestamp in Oracle 8i? What data type should I use and how to insert current Timestamp when an insert occurs?
    Thanx in advance.
    Nitin

    Well , no one needs to laugh on anyone's response. That could be because the way you explain was not clear enough. Nitin , whats the problem you are getting ? Do you want to use timestamp in Oracle ?

  • Mapping util.Date to Oracle timestamp

    Tuesday, March 22, 2005
    I am currently experiencing difficulty in mapping a java.util.Date
    field to an Oracle TIMESTAMP column.
    Here's what I see. By default, Kodo maps the date field to a DATE
    column. I suppose this makes sense since Oracle's date columns
    have time information that resolves to the second. In this case,
    the client has a business case to store subsecond resolution,
    hence the desire to store the date field in an Oracle TIMESTAMP
    column.
    First question: how should this be done?
    Here's what I've tried. I tried setting the jdbc-type extension
    for the date field to "timestamp". This setting makes no
    difference, and I suspect the reason is that OracleDBDictionary
    has made the mapping from TIMESTAMP to DATE.
    I tried setting the jdbc-sql-type extension for the date field to
    "timestamp". This makes a difference only when I drop the table.
    Then the schematool's refresh action creates a table with date's
    field mapped to a TIMESTAMP column. I have also gone ahead and
    manually altered the table to achieve the same effect.
    Once the mapping is created, I see the following behavior. Kodo
    has no problem reading the TIMESTAMP column and putting the info
    into the date field. It also has no problem saving non-null date
    values into the TIMESTAMP column. But it does have a problem
    storing a null in the date field.
    Second question: what is the workaround to this problem?
    The the stack dump (obtained by using the JDO Tools Library
    example) follows.
    Thanks in advance,
    David Ezzio
    enter command:
    --> return book
    Select the book to return:
    1. book [com.ysoft.jdo.book.library.Book-354] "Gone to War" checked out:
    Tue Mar 22 10:38:01 EST 2005
    2. book [com.ysoft.jdo.book.library.Book-356] "Gone to Work" checked
    out: Tue Mar 22 10:33:58 EST 2005
    3. book [com.ysoft.jdo.book.library.Book-357] "Gone Fishing" checked
    out: Tue Mar 22 10:33:58 EST 2005
    4. book [com.ysoft.jdo.book.library.Book-360] "Gone Sailing" checked
    out: Tue Mar 22 10:33:58 EST 2005
    5. book [com.ysoft.jdo.book.library.Book-355] "Gone Hunting" checked
    out: Tue Mar 22 10:33:58 EST 2005
    Enter selection:
    --> 2
    okay
    enter command:
    --> commit
    exception caught in command
    kodo.util.FatalDataStoreException: The transaction has been rolled back.
    See the nested exceptions for details on the errors that occu
    rred.
    at
    kodo.runtime.PersistenceManagerImpl.throwFlushException(PersistenceManagerImpl.java:1262)
    at
    kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:1122)
    at
    kodo.runtime.PersistenceManagerImpl.flushSafe(PersistenceManagerImpl.java:1005)
    at
    kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:932)
    at
    kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
    at
    kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:592)
    at
    com.ysoft.jdo.book.library.LibraryHandler.commitTransaction(LibraryHandler.java:175)
    at
    com.ysoft.jdo.book.library.client.CommitTransaction.execute(Library.java:279)
    at
    com.ysoft.jdo.book.common.console.UserInterface.execute(UserInterface.java:196)
    at
    com.ysoft.jdo.book.common.console.UserInterface.pumpCommands(UserInterface.java:186)
    at com.ysoft.jdo.book.library.client.Library.run(Library.java:139)
    at com.ysoft.jdo.book.library.client.Library.main(Library.java:104)
    NestedThrowablesStackTrace:
    kodo.util.DataStoreException: Invalid column type
    at
    kodo.jdbc.sql.DBDictionary.newDataStoreException(DBDictionary.java:3081)
    at kodo.jdbc.sql.SQLExceptions.getDataStore(SQLExceptions.java:77)
    at kodo.jdbc.sql.SQLExceptions.getDataStore(SQLExceptions.java:63)
    at kodo.jdbc.sql.SQLExceptions.getDataStore(SQLExceptions.java:43)
    at
    kodo.jdbc.runtime.PreparedStatementManager.flush(PreparedStatementManager.java:89)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:445)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:193)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:95)
    at
    kodo.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:609)
    at
    kodo.runtime.DelegatingStoreManager.flush(DelegatingStoreManager.java:153)
    at
    kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:1122)
    at
    kodo.runtime.PersistenceManagerImpl.flushSafe(PersistenceManagerImpl.java:1005)
    at
    kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:932)
    at
    kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
    at
    kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:592)
    at
    com.ysoft.jdo.book.library.LibraryHandler.commitTransaction(LibraryHandler.java:175)
    at
    com.ysoft.jdo.book.library.client.CommitTransaction.execute(Library.java:279)
    at
    com.ysoft.jdo.book.common.console.UserInterface.execute(UserInterface.java:196)
    at
    com.ysoft.jdo.book.common.console.UserInterface.pumpCommands(UserInterface.java:186)
    at com.ysoft.jdo.book.library.client.Library.run(Library.java:139)
    at com.ysoft.jdo.book.library.client.Library.main(Library.java:104)
    NestedThrowablesStackTrace:
    java.sql.SQLException: Invalid column type
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
    at
    oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:6164)
    at
    oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:1316)
    at
    com.solarmetric.jdbc.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:369)
    at
    com.solarmetric.jdbc.PoolConnection$PoolPreparedStatement.setNull(PoolConnection.java:406)
    at
    com.solarmetric.jdbc.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:369)
    at
    com.solarmetric.jdbc.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:369)
    at
    com.solarmetric.jdbc.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:369)
    at
    com.solarmetric.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.setNull(LoggingConnectionDecorato
    r.java:792)
    at
    com.solarmetric.jdbc.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:369)
    at kodo.jdbc.sql.DBDictionary.setNull(DBDictionary.java:950)
    at
    kodo.jdbc.sql.OracleDictionary.setNull(OracleDictionary.java:450)
    at kodo.jdbc.sql.RowImpl.toSQL(RowImpl.java:828)
    at kodo.jdbc.sql.RowImpl.flush(RowImpl.java:1039)
    at kodo.jdbc.sql.RowImpl.flush(RowImpl.java:975)
    at
    kodo.jdbc.runtime.PreparedStatementManager.flushInternal(PreparedStatementManager.java:160)
    at
    kodo.jdbc.runtime.PreparedStatementManager.flush(PreparedStatementManager.java:84)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:445)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:193)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:95)
    at
    kodo.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:609)
    at
    kodo.runtime.DelegatingStoreManager.flush(DelegatingStoreManager.java:153)
    at
    kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:1122)
    at
    kodo.runtime.PersistenceManagerImpl.flushSafe(PersistenceManagerImpl.java:1005)
    at
    kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:932)
    at
    kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
    at
    kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:592)
    at
    com.ysoft.jdo.book.library.LibraryHandler.commitTransaction(LibraryHandler.java:175)
    at
    com.ysoft.jdo.book.library.client.CommitTransaction.execute(Library.java:279)
    at
    com.ysoft.jdo.book.common.console.UserInterface.execute(UserInterface.java:196)
    at
    com.ysoft.jdo.book.common.console.UserInterface.pumpCommands(UserInterface.java:186)
    at com.ysoft.jdo.book.library.client.Library.run(Library.java:139)
    at com.ysoft.jdo.book.library.client.Library.main(Library.java:104)
    enter command:
    -->

    Hi Stephen,
    There are two related issues that are addressed. One, some Oracle
    drivers return the wrong type (Type.OTHER) for the TIMESTAMP field.
    This is true for the
    9.2.0.1.0 driver that ships with 9iR2. This causes an exception when
    attempting to assign a null to the date field that has been mapped to a
    TIMESTAMP column. Two, all of the 9i drivers (and 10g drivers) return a
    type name of "TIMESTAMP(x)" where x is the precision. This confuses
    Kodo's OracleDictionary which is looking for a string without the
    precision characters.
    Following your suggestion, the following code fixes it just fine. It is
    harmless, in that all it does is do what OracleDictionary intended but
    failed to do. To use it, you must add the following property
    configuration to the kodo.properties file.
    kodo.jdbc.DBDictionary: xxx.jdo.FixedOracleDictionary
    Without the fix, Kodo does not reassign the TIMESTAMP columns to a type
    of DATE. So far as I can tell, as long as the driver returns a
    Types.TIMESTAMP this does not cause a failure.
    This fix will be moot as soon as the bug in OracleDictionary is fixed.
    What I wonder about is why does Kodo reassign type TIMESTAMP to DATE?
    Why don't you treat TIMESTAMP types as TIMESTAMP types? Curious minds
    want to know.
    Best wishes,
    David
    ---- code follows
    package xxx.jdo;
    import java.sql.*;
    import kodo.jdbc.schema.*;
    import kodo.jdbc.sql.*;
    * Some Oracle drivers do not return the correct type for the TIMESTAMP
    field.
    * This class fixes this issue for Kodo 3.3. The problem (an exception
    complaining
    * about an invalid column type) appears when mapping a Java field
    (Date for example) to
    * an Oracle timestamp field, and only when attempting to set null on
    the Java field.
    public class FixedOracleDictionary
    extends OracleDictionary
    public Column[] getColumns (DatabaseMetaData meta, String catalog,
    String schemaName, String tableName,
    String columnName, Connection conn)
    throws SQLException
    // Let Kodo's OracleDictionary do its thing
    Column[] cols = super.getColumns (meta, catalog, schemaName,
    tableName,
    columnName, conn);
    // Catch the columns with a name of "TIMESTAMP(n)" and mark them
    as DATE types.
    // This is what the OracleDictionary intended to do, but was
    foiled by the
    // name which now has a precision.
    for (int i = 0; cols != null && i < cols.length; i++)
    String tName = cols.getTypeName();
    if (tName != null && tName.startsWith("TIMESTAMP"))
    cols[i].setType(Types.DATE);
    return cols;
    ---- code ends
    Stephen Kim wrote:
    This is a bug (1111)with regards to specific combinations of Oracle 10
    driver and db.
    To work around the issue until the next relase, getColumns (...) in
    OracleDictionary needs to be extended/modified to instead of doing a
    strict equals () comparison to "TIMESTAMP", to instead do a startsWith
    ("TIMESTAMP")
    David Ezzio wrote:
    Tuesday, March 22, 2005
    I am currently experiencing difficulty in mapping a java.util.Date
    field to an Oracle TIMESTAMP column.
    Here's what I see. By default, Kodo maps the date field to a DATE
    column. I suppose this makes sense since Oracle's date columns
    have time information that resolves to the second. In this case,
    the client has a business case to store subsecond resolution,
    hence the desire to store the date field in an Oracle TIMESTAMP
    column.
    First question: how should this be done?
    Here's what I've tried. I tried setting the jdbc-type extension
    for the date field to "timestamp". This setting makes no
    difference, and I suspect the reason is that OracleDBDictionary
    has made the mapping from TIMESTAMP to DATE.
    I tried setting the jdbc-sql-type extension for the date field to
    "timestamp". This makes a difference only when I drop the table.
    Then the schematool's refresh action creates a table with date's
    field mapped to a TIMESTAMP column. I have also gone ahead and
    manually altered the table to achieve the same effect.
    Once the mapping is created, I see the following behavior. Kodo
    has no problem reading the TIMESTAMP column and putting the info
    into the date field. It also has no problem saving non-null date
    values into the TIMESTAMP column. But it does have a problem
    storing a null in the date field.
    Second question: what is the workaround to this problem?
    The the stack dump (obtained by using the JDO Tools Library
    example) follows.
    Thanks in advance,
    David Ezzio
    enter command:
    --> return book
    Select the book to return:
    1. book [com.ysoft.jdo.book.library.Book-354] "Gone to War" checked
    out:
    Tue Mar 22 10:38:01 EST 2005
    2. book [com.ysoft.jdo.book.library.Book-356] "Gone to Work" checked
    out: Tue Mar 22 10:33:58 EST 2005
    3. book [com.ysoft.jdo.book.library.Book-357] "Gone Fishing" checked
    out: Tue Mar 22 10:33:58 EST 2005
    4. book [com.ysoft.jdo.book.library.Book-360] "Gone Sailing" checked
    out: Tue Mar 22 10:33:58 EST 2005
    5. book [com.ysoft.jdo.book.library.Book-355] "Gone Hunting" checked
    out: Tue Mar 22 10:33:58 EST 2005
    Enter selection:
    --> 2
    okay
    enter command:
    --> commit
    exception caught in command
    kodo.util.FatalDataStoreException: The transaction has been rolled
    back. See the nested exceptions for details on the errors that occu
    rred.
    at
    kodo.runtime.PersistenceManagerImpl.throwFlushException(PersistenceManagerImpl.java:1262)
    at
    kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:1122)
    at
    kodo.runtime.PersistenceManagerImpl.flushSafe(PersistenceManagerImpl.java:1005)
    at
    kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:932)
    at
    kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
    at
    kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:592)
    at
    com.ysoft.jdo.book.library.LibraryHandler.commitTransaction(LibraryHandler.java:175)
    at
    com.ysoft.jdo.book.library.client.CommitTransaction.execute(Library.java:279)
    at
    com.ysoft.jdo.book.common.console.UserInterface.execute(UserInterface.java:196)
    at
    com.ysoft.jdo.book.common.console.UserInterface.pumpCommands(UserInterface.java:186)
    at
    com.ysoft.jdo.book.library.client.Library.run(Library.java:139)
    at
    com.ysoft.jdo.book.library.client.Library.main(Library.java:104)
    NestedThrowablesStackTrace:
    kodo.util.DataStoreException: Invalid column type
    at
    kodo.jdbc.sql.DBDictionary.newDataStoreException(DBDictionary.java:3081)
    at
    kodo.jdbc.sql.SQLExceptions.getDataStore(SQLExceptions.java:77)
    at
    kodo.jdbc.sql.SQLExceptions.getDataStore(SQLExceptions.java:63)
    at
    kodo.jdbc.sql.SQLExceptions.getDataStore(SQLExceptions.java:43)
    at
    kodo.jdbc.runtime.PreparedStatementManager.flush(PreparedStatementManager.java:89)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:445)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:193)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:95)
    at
    kodo.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:609)
    at
    kodo.runtime.DelegatingStoreManager.flush(DelegatingStoreManager.java:153)
    at
    kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:1122)
    at
    kodo.runtime.PersistenceManagerImpl.flushSafe(PersistenceManagerImpl.java:1005)
    at
    kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:932)
    at
    kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
    at
    kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:592)
    at
    com.ysoft.jdo.book.library.LibraryHandler.commitTransaction(LibraryHandler.java:175)
    at
    com.ysoft.jdo.book.library.client.CommitTransaction.execute(Library.java:279)
    at
    com.ysoft.jdo.book.common.console.UserInterface.execute(UserInterface.java:196)
    at
    com.ysoft.jdo.book.common.console.UserInterface.pumpCommands(UserInterface.java:186)
    at
    com.ysoft.jdo.book.library.client.Library.run(Library.java:139)
    at
    com.ysoft.jdo.book.library.client.Library.main(Library.java:104)
    NestedThrowablesStackTrace:
    java.sql.SQLException: Invalid column type
    at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
    at
    oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:6164)
    at
    oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:1316)
    at
    com.solarmetric.jdbc.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:369)
    at
    com.solarmetric.jdbc.PoolConnection$PoolPreparedStatement.setNull(PoolConnection.java:406)
    at
    com.solarmetric.jdbc.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:369)
    at
    com.solarmetric.jdbc.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:369)
    at
    com.solarmetric.jdbc.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:369)
    at
    com.solarmetric.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.setNull(LoggingConnectionDecorato
    r.java:792)
    at
    com.solarmetric.jdbc.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:369)
    at kodo.jdbc.sql.DBDictionary.setNull(DBDictionary.java:950)
    at
    kodo.jdbc.sql.OracleDictionary.setNull(OracleDictionary.java:450)
    at kodo.jdbc.sql.RowImpl.toSQL(RowImpl.java:828)
    at kodo.jdbc.sql.RowImpl.flush(RowImpl.java:1039)
    at kodo.jdbc.sql.RowImpl.flush(RowImpl.java:975)
    at
    kodo.jdbc.runtime.PreparedStatementManager.flushInternal(PreparedStatementManager.java:160)
    at
    kodo.jdbc.runtime.PreparedStatementManager.flush(PreparedStatementManager.java:84)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:445)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:193)
    at
    kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:95)
    at
    kodo.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:609)
    at
    kodo.runtime.DelegatingStoreManager.flush(DelegatingStoreManager.java:153)
    at
    kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:1122)
    at
    kodo.runtime.PersistenceManagerImpl.flushSafe(PersistenceManagerImpl.java:1005)
    at
    kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:932)
    at
    kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
    at
    kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:592)
    at
    com.ysoft.jdo.book.library.LibraryHandler.commitTransaction(LibraryHandler.java:175)
    at
    com.ysoft.jdo.book.library.client.CommitTransaction.execute(Library.java:279)
    at
    com.ysoft.jdo.book.common.console.UserInterface.execute(UserInterface.java:196)
    at
    com.ysoft.jdo.book.common.console.UserInterface.pumpCommands(UserInterface.java:186)
    at
    com.ysoft.jdo.book.library.client.Library.run(Library.java:139)
    at
    com.ysoft.jdo.book.library.client.Library.main(Library.java:104)
    enter command:
    -->

  • Oracle Timestamp and java.util.date

    Greetings,
    【Enviroment】
    oracle 10g Express
    jdbc 10.2.0.1.0 thin driver
    windows Xp professinal
    【problem】
    I fetched a value of timestamp.
    And I faced An Error that "java.sql.SQLException: Cannot set lastup_dt: incompatible types."
    We define data type of lastup_dt is timestamp on Oracle.
    And We define the data type of lastup_dt of javaBean is java.util.date.
    And Ocurr SQLException at result = rsh.handle(rs);
    How Can I avoid it?
    public Object query(Connection conn, String sql, Object[] params,
    ResultSetHandler rsh) throws SQLException {
    PreparedStatement stmt = null;
    ResultSet rs = null;
    Object result = null;
    try {
    stmt = this.prepareStatement(conn, sql);
    this.fillStatement(stmt, params);
    rs = this.wrap(stmt.executeQuery());
    result = rsh.handle(rs);
    } catch (SQLException e) {
    this.rethrow(e, sql, params);
    } finally {
    try {
    close(rs);
    } finally {
    close(stmt);
    return result;
    Any help I appreciate it.
    Thank you.

    As long as you have the long representation of the time you can create a new java.util.Date:
    new java.util.Date(ts.getTime())

  • How to convert oracle timestamp to java timestamp

    Hi,
    I need to convert oracle timestamp that i got from oracle database to java timestamp.I tried to use getTimestamp() to get timestamp value from oracle, but am getting NumberFormatException.
    Could any of suggest how to convert oracle timestamp to java timestamp.

    Thanks jverd ,
    then my code will be like:
    String oracleTS="11-MAR-05 11.19.20.625 AM";
    // am looking for yyyy-MM-dd HH:mm:ss format
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd
    HH:mm:ss");           
    Timestamp javaTimestamp=Timestamp.valueOf(oracleTS);
    System.out.println("javaTimestamp----->>
    "+javaTimestamp);
    ving java.lang.NumberFormatException: For input
    string: "MAR"Well, the SimpleDateFormat has to actually match the format you're trying to parse, for one thing. Then you have to actually USE the SDF, which you didn't.
    You really haven't made it clear what you're trying to do, and it doesn't appear that you bothered to study the links I provided.
    DateFormat df = new SimpleDateFormat("dd-MMM-yy HH.mm.ss.SSS aa");
    Date date = df.parse(oracleTS);
    Timestamp ts = new Timestamp(date.getTime());

  • How to convert normal timestamp to julian timestamp in oracle

    Hi Friends
    How can i convert normal timestamp to Julian Timestamp in Oracle ?
    Thanks for your help

    Hi Chris,
    I dont have any idea on this. But need clarification on your query.
    When I executing below query I'm getting same output. 'J' will give only Julian day right not the timestamp. Please correct me if I am wrong.
    SQL> select to_char(systimestamp,'J') J,to_char(sysdate,'J') from dual;
    J            TO_CHAR
    2456631   2456631
    http://en.wikipedia.org/wiki/Template:JULIANDAY.TIMESTAMP

  • Problem for displaying oracle timestamp(6) or timestamp(9) on editor

    I am trying to display table contents on Data -> Edit. but the data on columns with timestamp(6) or timestamp(9) data type is not showing up correctly. It is showing up as '<error>'.
    Does anybody know any workaround or solution to this issue?
    Thanks.

    I created a simple test using following schema:
    CREATE TABLE ts_test (
    ts TIMESTAMP(9));
    INSERT INTO ts_test
    (ts)
    VALUES
    (timestamp'2009-08-08 09:00:00.123456789');
    The value DOES show up in editor. Did you format the value using timestamp function before inserting?
    Can you post your SQL statement for inserting values?
    BTW, even SELECT was OK for me, the updating seems broken - the SQL statement generated was wrong.
    I will log an internal bug and have this fixed in next release.
    For now, you may workaround by creating a SQL file and update using SQL statement.

  • UNIX time to Oracle time

    Hallo,
    I am acquiring the data for my reports in a UNIX evironment using embedded SQL.
    Therefore I am searching for a function that converts the UNIX time to ORACLE time. Currently I am doing the conversion via a string representation but I would prefer a function that does it on a binary level.
    Thanks a lot - Ulrich

    maybe (using the link provided) ;)
    select case when :unixts between -2114380800 and 2145916799
                then TO_DATE('19700101000000','YYYYMMDDHH24MISS') + NUMTODSINTERVAL(:unixts,'SECOND')
           end the_date
      from dualRegards
    Etbin

  • Sybase to Oracle Data Conversion

    Whats the quickest way to move data from Sybase to Oracle ? What options are available ?
    Database objects (table ddls, procs, triggers - everything else is already in place in Oracle) - already provided by Vendor.
    Overview about the database :
    Datatype difference
    Sybase datetime converted to Oracle Timestamp
    Other datatypes are related
    int - int
    char - char
    varchar - varchar
    Timestamps are part of PK & FK in few tables.
    Approx 1000 tables to convert
    Some tables have 25- 75 million rows
    Thank you
    Yog

    Another approach you might like to try is to use the manual approach of data migration.. where underlying idea is to bcp out the data from Sybase and thereafter use sqlloader to load data into the oracle tables.. and if you happen tro use DIRECT=TRUE with sqlloader nothing better.... its really fast..
    sql developer would generate the bcp out script.. extract the scripts... run them on the sybase host ...move the dump files to oracle host... run the sqlloader scripts..
    AT our end 15G worth data migration took 1 day using sql developer but the manual approach would do the stuff in 3-4 hours.
    Anyway would like to put 1 issue I am facing..
    In sybase the datetime contains the values to the level of Milisecond whereas when it comes to date column in Oracle it is just to the level of seconds .. => that if there is a primary key sybase table column.. and this truncation at orale level would make the inserts to fail with duplication errors... any thoughts on how to overcome this problem....
    Thanks
    Praveen

  • Differences between Oracle 8i for a UNIX Platform and Oracle 8i for a Linux Platform

    Hello,
    J would like to know if there are some differences between Oracle 8i for a UNIX Platform and Oracle 8i for a Linux Platform.
    I know that there are some differences on Oracle 8i Parallel Server and i know that some products are not include like precompiler (Mod*Ada, Pro*FORTRAN) on a Linux Platform.
    Thank you.

    We have installed Oracle 8i on Solaris 8 and it had a great performance, of course that the hardware and licence invested here was costed my the office where i work. Personaly i'd installed linux reh hat 8 and oracle 8i, imagine that, it could be implemented by any individual that has the time to do so.
    By buyinng from a company that has a good background you could be sure that you will have support.
    Bottom line, if you have the $ to buy great hardware go for a unix platform. But if you don't a Red Hat Linux Server Licence with a 1 year sopport and Oracle data base is about 3500Dls.
    Visit www.red-hat.com
    Rewards... Bye

  • How to create pdf files in UNIX directory from oracle reports

    I would like to know how to create pdf files in UNIX directory from oracle reports.
    Thanks,

    Please make your question more clear . Also mention the reports version.
    1) If you are runnning reports in Unix, you can give
    .... destype=file desformat=pdf desname=<filename>
    in command line
    Please refer docs below.
    2) If by your question you mean
    "My reports server is running in Windows but I want to ftp my files to Unix after creating it"
    then the answer is that you can use pluggable destination "ftp"
    .... destype=ftp desformat=pdf desname=<ftp url>
    Pluggable destinations download
    http://otn.oracle.com/products/reports/pluginxchange/index.html
    Thanks
    Ratheesh
    [    All Docs     ]
    http://otn.oracle.com/documentation/reports.html
    [     Publishing reports to web  - 10G  ]
    http://download.oracle.com/docs/html/B10314_01/toc.htm (html)
    http://download.oracle.com/docs/pdf/B10314_01.pdf (pdf)
    [   Building reports  - 10G ]
    http://download.oracle.com/docs/pdf/B10602_01.pdf (pdf)
    http://download.oracle.com/docs/html/B10602_01/toc.htm (html)
    [   Forms Reports Integration whitepaper  9i ]
    http://otn.oracle.com/products/forms/pdf/frm9isrw9i.pdf

Maybe you are looking for

  • Database connection not working across all Adobe programs

    I have a PDF form connected to an Access database via ODBC. On the form, I created a button that, when clicked, takes the data in the PDF and adds it to the database. The scripts for that action and the connection was established in LiveCycle Designe

  • Install ERP ECC 6.0 with MSCS High Availability error~

    Dear Expert: After I install the ASCS, the next step is install the first node... but during the 'Enter the sap instance parameters' it occured an error: Cannot find an 'Abap SCS' SAP instance appropriate for clustering. SOLUTION:Check your input dat

  • Export/import preferences configurations?

    greetings, back in the olden days, before OSX, i used to save my systems configurations. for example, os9 and before, i could save my locations, printers, etc... i have both a desktop and a macbook pro, and at home a powerbook and a new MBPro and som

  • Convert .swf to .flv

    I would like to figure out how to convert a .swf file created with Captivate to .flv. .flv seems to intergrate better with Dreamweaver. You can simply insert .flv with Dreamweaver, but this does not seem to be the case with .swf. I have tried to impo

  • Converting a dfnt to tt or otf

    I have a dfnt (skia) that I can see and use all the faces in the family in some apps but not in others. I was going to convert to otf using fontxchange but everytime I export only Skia Regular shows as an OTF font. The other family members don't. Is