<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How do I preserve a timestamp(6): Oracle to PostgresSQL in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-do-I-preserve-a-timestamp-6-Oracle-to-PostgresSQL/m-p/2365107#M128753</link>
    <description>&lt;P&gt;&lt;B&gt;Scenario: &lt;/B&gt;&lt;/P&gt;&lt;P&gt;I have an incredibly simple flow:&amp;nbsp;tDbOracleInput --&amp;gt; tMap --&amp;gt; tDbPostgresqlOutput&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;TLDR:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;How do I get an Oracle&amp;nbsp;timestamp(6) into PostgresSQL timestamp(6) without losing any precision?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Issue&amp;nbsp;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;Reading from source table: A mask of "yyyy-MM-dd HH:mm:ss.SSS" only transfers the first three digits. A timestamp mask of "yyyy-MM-dd HH:mm:ss.SSSSSS" causes issues in that only the first three digits are parsed and appended to '000'; thus "2023-11-12 15:45:00.123456" becomes either "2023-11-12 15:45:00.123" or "2023-11-12 15:45:00.000123"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attempted to ameliorate this by using the Oracle to_char() function when selecting the field: i.e. to_char(GG_TSTAMP, 'YYYY-MM-DD HH24:MI:SS.FF6' ) which brings back the string form correctly.&amp;nbsp;But this leads to the second problem in that the tMap also uses a java.util.Date in it's output schema and again, I'm losing digits. I assuming this is happening because internally because java.util.Date does not support the formatting of greater then milliseconds and that maybe it's not using the Java8 java.time classes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within the tMap I have converted the given timestamp string into a Date via the following function so I'm almost convinced that this is Talend and not me!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	public static Date fromTimestamp(final String timestamp)&amp;nbsp;&lt;/P&gt;&lt;P&gt;	{&lt;/P&gt;&lt;P&gt;		// Note: timezones are not relevant here; need a verbatim copy&lt;/P&gt;&lt;P&gt;	&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;		DateTimeFormatter parser = new DateTimeFormatterBuilder()&lt;/P&gt;&lt;P&gt;		&amp;nbsp;&amp;nbsp;.append(DateTimeFormatter.ISO_LOCAL_DATE)&lt;/P&gt;&lt;P&gt;		&amp;nbsp;&amp;nbsp;.appendLiteral(' ')&lt;/P&gt;&lt;P&gt;		&amp;nbsp;&amp;nbsp;.append(DateTimeFormatter.ISO_LOCAL_TIME)&lt;/P&gt;&lt;P&gt;		&amp;nbsp;&amp;nbsp;.toFormatter(Locale.ENGLISH);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;		LocalDateTime localDateTime = LocalDateTime.from(parser.parse(timestamp));&lt;/P&gt;&lt;P&gt;		Long epoch = ZonedDateTime.of(localDateTime, ZoneId.systemDefault()).toInstant().toEpochMilli();&lt;/P&gt;&lt;P&gt;		Date epochDate = java.sql.Timestamp.valueOf(localDateTime);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;		System.out.println("----------------------------------------------------------------------");&lt;/P&gt;&lt;P&gt;		System.out.println("----&amp;gt; Request for Date from: " + timestamp);&lt;/P&gt;&lt;P&gt;		System.out.println("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;localDateTime: " + localDateTime.format(parser));&lt;/P&gt;&lt;P&gt;		System.out.println("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;epoch: " + epoch.toString());&lt;/P&gt;&lt;P&gt;		System.out.println("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Date: " + epochDate.toString());&lt;/P&gt;&lt;P&gt;		System.out.println("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Date instant: " + epochDate.toInstant().toString());&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;		return epochDate ;&lt;/P&gt;&lt;P&gt;	}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All ideas greatfully received; this column is a synchronisation timestamp and is an important field for us.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Nov 2024 21:12:57 GMT</pubDate>
    <dc:creator>stucas</dc:creator>
    <dc:date>2024-11-15T21:12:57Z</dc:date>
    <item>
      <title>How do I preserve a timestamp(6): Oracle to PostgresSQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-do-I-preserve-a-timestamp-6-Oracle-to-PostgresSQL/m-p/2365107#M128753</link>
      <description>&lt;P&gt;&lt;B&gt;Scenario: &lt;/B&gt;&lt;/P&gt;&lt;P&gt;I have an incredibly simple flow:&amp;nbsp;tDbOracleInput --&amp;gt; tMap --&amp;gt; tDbPostgresqlOutput&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;TLDR:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;How do I get an Oracle&amp;nbsp;timestamp(6) into PostgresSQL timestamp(6) without losing any precision?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Issue&amp;nbsp;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;Reading from source table: A mask of "yyyy-MM-dd HH:mm:ss.SSS" only transfers the first three digits. A timestamp mask of "yyyy-MM-dd HH:mm:ss.SSSSSS" causes issues in that only the first three digits are parsed and appended to '000'; thus "2023-11-12 15:45:00.123456" becomes either "2023-11-12 15:45:00.123" or "2023-11-12 15:45:00.000123"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attempted to ameliorate this by using the Oracle to_char() function when selecting the field: i.e. to_char(GG_TSTAMP, 'YYYY-MM-DD HH24:MI:SS.FF6' ) which brings back the string form correctly.&amp;nbsp;But this leads to the second problem in that the tMap also uses a java.util.Date in it's output schema and again, I'm losing digits. I assuming this is happening because internally because java.util.Date does not support the formatting of greater then milliseconds and that maybe it's not using the Java8 java.time classes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within the tMap I have converted the given timestamp string into a Date via the following function so I'm almost convinced that this is Talend and not me!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	public static Date fromTimestamp(final String timestamp)&amp;nbsp;&lt;/P&gt;&lt;P&gt;	{&lt;/P&gt;&lt;P&gt;		// Note: timezones are not relevant here; need a verbatim copy&lt;/P&gt;&lt;P&gt;	&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;		DateTimeFormatter parser = new DateTimeFormatterBuilder()&lt;/P&gt;&lt;P&gt;		&amp;nbsp;&amp;nbsp;.append(DateTimeFormatter.ISO_LOCAL_DATE)&lt;/P&gt;&lt;P&gt;		&amp;nbsp;&amp;nbsp;.appendLiteral(' ')&lt;/P&gt;&lt;P&gt;		&amp;nbsp;&amp;nbsp;.append(DateTimeFormatter.ISO_LOCAL_TIME)&lt;/P&gt;&lt;P&gt;		&amp;nbsp;&amp;nbsp;.toFormatter(Locale.ENGLISH);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;		LocalDateTime localDateTime = LocalDateTime.from(parser.parse(timestamp));&lt;/P&gt;&lt;P&gt;		Long epoch = ZonedDateTime.of(localDateTime, ZoneId.systemDefault()).toInstant().toEpochMilli();&lt;/P&gt;&lt;P&gt;		Date epochDate = java.sql.Timestamp.valueOf(localDateTime);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;		System.out.println("----------------------------------------------------------------------");&lt;/P&gt;&lt;P&gt;		System.out.println("----&amp;gt; Request for Date from: " + timestamp);&lt;/P&gt;&lt;P&gt;		System.out.println("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;localDateTime: " + localDateTime.format(parser));&lt;/P&gt;&lt;P&gt;		System.out.println("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;epoch: " + epoch.toString());&lt;/P&gt;&lt;P&gt;		System.out.println("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Date: " + epochDate.toString());&lt;/P&gt;&lt;P&gt;		System.out.println("&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Date instant: " + epochDate.toInstant().toString());&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;		return epochDate ;&lt;/P&gt;&lt;P&gt;	}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All ideas greatfully received; this column is a synchronisation timestamp and is an important field for us.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 21:12:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-do-I-preserve-a-timestamp-6-Oracle-to-PostgresSQL/m-p/2365107#M128753</guid>
      <dc:creator>stucas</dc:creator>
      <dc:date>2024-11-15T21:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I preserve a timestamp(6): Oracle to PostgresSQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-do-I-preserve-a-timestamp-6-Oracle-to-PostgresSQL/m-p/2365108#M128754</link>
      <description>&lt;P&gt;So, I have found a work around, but to me this is something that should not need to be done:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Read the timestamp from source DB as a string (fomatted as required)&lt;/P&gt;&lt;P&gt;2. Pass this though the tMap (again as a string)&lt;/P&gt;&lt;P&gt;3. In the tDBoutput use the "Additional Columns" (under advanced) to use field replacment, converting the string back into a timestamp&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000tE7OyAAK.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/145307iF525916BC58F4FAC/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000tE7OyAAK.png" alt="0695b00000tE7OyAAK.png" /&gt;&lt;/span&gt;Why I think it's a problem&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Firstly this means that you cannot use the metadata created from reading a database table's defintion - the timestamps (or other columns) need to be a string and that means you're into having to save an almost duplicate version of the table as a "generic schema" - ths makes code confsing and increases maintenance overhead.&lt;/LI&gt;&lt;LI&gt;It seems to me that conversion of a "timestamp" field in a RDBMS should not be intepreted as java.util.Date; it should be using something more akin to &lt;A href="https://docs.oracle.com/javase/8/docs/api/java/sql/Timestamp.html" alt="https://docs.oracle.com/javase/8/docs/api/java/sql/Timestamp.html" target="_blank"&gt;java.sql.Timestamp&lt;/A&gt; object (derived from Date)&lt;/LI&gt;&lt;LI&gt;If I do chnage the inbound outbound type to "TIMESTAMP" the tDbInput gives a warning "The schema's DB type is not correct for this component". &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm searching for neater "solution" ...  but this will get me&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 08:28:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-do-I-preserve-a-timestamp-6-Oracle-to-PostgresSQL/m-p/2365108#M128754</guid>
      <dc:creator>stucas</dc:creator>
      <dc:date>2023-11-30T08:28:21Z</dc:date>
    </item>
  </channel>
</rss>

