<?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 [resolved] Adding Short type from database with null values in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317981#M88364</link>
    <description>I'm fairly new to both Java and Talend. I've spent a couple hours now trying to find a solution to this. 
&lt;BR /&gt;I have a database with 2 columns: 
&lt;BR /&gt;CourseActions1 SmallInt NULL 
&lt;BR /&gt;CourseActions2 SmallInt NULL 
&lt;BR /&gt;When I bring those into Talend through a tMysqlInput, the values are brought in as a Java type Short. 
&lt;BR /&gt;I need to pass these into a different database table with 3 columns: 
&lt;BR /&gt;CourseActions1 SmallInt NULL 
&lt;BR /&gt;CourseActions2 SmallInt NULL 
&lt;BR /&gt;TotalActions SmallInt NOT NULL 
&lt;BR /&gt;You see that both database allows these values to be Null. There are several hundred rows of null values and they need to transfer as null into their respective field. But I need to add the 2 source fields to create the new Total column. 
&lt;BR /&gt;When I simply transfer these rows through a tMap, no problem. Null values are transferred as they should. But I cannot figure out how to add them together. I keep getting a null pointer error. I assume that's a Java thing where Short can't be null so (null + 0) results in an error. 
&lt;BR /&gt;Is there anyway to validate a null value against a Short type and replace it with 0 when adding? 
&lt;BR /&gt;I've tried this as an expression in the tMap component: 
&lt;BR /&gt;(row1.CourseActions1.toString() != null ? row1.CourseActions1 : 0) + (row1.CourseActions2.toString() != null ? row1.CourseActions2 : 0) 
&lt;BR /&gt;Any help is appreciated.</description>
    <pubDate>Thu, 17 Apr 2014 00:01:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-04-17T00:01:39Z</dc:date>
    <item>
      <title>[resolved] Adding Short type from database with null values</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317981#M88364</link>
      <description>I'm fairly new to both Java and Talend. I've spent a couple hours now trying to find a solution to this. 
&lt;BR /&gt;I have a database with 2 columns: 
&lt;BR /&gt;CourseActions1 SmallInt NULL 
&lt;BR /&gt;CourseActions2 SmallInt NULL 
&lt;BR /&gt;When I bring those into Talend through a tMysqlInput, the values are brought in as a Java type Short. 
&lt;BR /&gt;I need to pass these into a different database table with 3 columns: 
&lt;BR /&gt;CourseActions1 SmallInt NULL 
&lt;BR /&gt;CourseActions2 SmallInt NULL 
&lt;BR /&gt;TotalActions SmallInt NOT NULL 
&lt;BR /&gt;You see that both database allows these values to be Null. There are several hundred rows of null values and they need to transfer as null into their respective field. But I need to add the 2 source fields to create the new Total column. 
&lt;BR /&gt;When I simply transfer these rows through a tMap, no problem. Null values are transferred as they should. But I cannot figure out how to add them together. I keep getting a null pointer error. I assume that's a Java thing where Short can't be null so (null + 0) results in an error. 
&lt;BR /&gt;Is there anyway to validate a null value against a Short type and replace it with 0 when adding? 
&lt;BR /&gt;I've tried this as an expression in the tMap component: 
&lt;BR /&gt;(row1.CourseActions1.toString() != null ? row1.CourseActions1 : 0) + (row1.CourseActions2.toString() != null ? row1.CourseActions2 : 0) 
&lt;BR /&gt;Any help is appreciated.</description>
      <pubDate>Thu, 17 Apr 2014 00:01:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317981#M88364</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-17T00:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Adding Short type from database with null values</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317982#M88365</link>
      <description>Hi sbaer, 
&lt;BR /&gt;Based on your post - you want to add whatever number comes in columns CourseAction1 and CourseAction2 and put its value inside TotalActions. During this ignore all null values. so following is the way 
&lt;BR /&gt;(CourseAction1?null:0:CourseAction1)+(CourseAction2?null:0:CourseAction2) 
&lt;BR /&gt;use above expression inside tMap for your TotalActions column. 
&lt;BR /&gt;Vaibhav</description>
      <pubDate>Thu, 17 Apr 2014 06:22:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317982#M88365</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-17T06:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Adding Short type from database with null values</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317983#M88366</link>
      <description>Thank you for your response.
&lt;BR /&gt;When I placed your expression inside tMap, I got errors:
&lt;BR /&gt;1. Cannot convert from Short to Boolean
&lt;BR /&gt;2. Syntax error on token":", . expected
&lt;BR /&gt;It doesn't seem that it recognizes this structure.
&lt;BR /&gt;(CourseAction1?null:0:CourseAction1)</description>
      <pubDate>Thu, 17 Apr 2014 17:01:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317983#M88366</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-17T17:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Adding Short type from database with null values</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317984#M88367</link>
      <description>I was sure I had already tried this, but when I put this in just barely it worked.
&lt;BR /&gt;(short)((row1.CourseActions1 != null ? row1.CourseActions1 : 0) + (row1.CourseActions2 != null ? row1.CourseActions2 : 0))
&lt;BR /&gt;I checked each piece separately and didn't get errors. When I added the two together I got an error about converting type int to Short. So I found somewhere to add the (short) to the front to cast it, and all the rows were correctly inserted into the database.</description>
      <pubDate>Thu, 17 Apr 2014 20:55:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317984#M88367</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-17T20:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Adding Short type from database with null values</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317985#M88368</link>
      <description>Good...</description>
      <pubDate>Fri, 18 Apr 2014 06:01:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Adding-Short-type-from-database-with-null-values/m-p/2317985#M88368</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-18T06:01:58Z</dc:date>
    </item>
  </channel>
</rss>

