Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Can I assign a default value to NULL integers without an expression?

Hi, here is my scenario (my target table is MySQL):
One of my lookup tables has rows with no value, or NULLs
I'd like to get the value of -1 into these rows in the target table
I can write an expression for this in the tMap, but shouldn't MySQL be able to add the -1s in itself?
Here is what I have tried:
1. The source lookup table schema as not NULLable, as it itself does not have any NULLs in it. This produced 0s in my target table
2. The source lookup table as NULLable; this was necessary to actually get NULLs i.e. non-0 values into the target table, unexpectedly
3. Setting the source to NULLable and the target to not NULLable, hoping to let MySQL do it's thing and insert the default value of -1 when it hits a NULLable field. This produced a java.lang.NullPointerException
Am I thus forced to write an expression such as "row1.column == null ? -1 : row1.column" into my tMap?
Just trying to balance the functions of the different platforms rather than perform redundant actions
Thanks 0683p000009MACn.png
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Your 3. solution cannot work, because Java do the an implicit call to e.g. the method intValue() to an Integer to fill the int (none null) output. If the input is null, it fails.
The default values in the database will only be used if you do not fill the column and set null as value is always a attempt to fill the column and prevents the database from setting the default value.
The only way is indeed the expression you already know in the tMap.

View solution in original post

2 Replies
Anonymous
Not applicable
Author

Your 3. solution cannot work, because Java do the an implicit call to e.g. the method intValue() to an Integer to fill the int (none null) output. If the input is null, it fails.
The default values in the database will only be used if you do not fill the column and set null as value is always a attempt to fill the column and prevents the database from setting the default value.
The only way is indeed the expression you already know in the tMap.
Anonymous
Not applicable
Author

Ok thanks for the explanation 0683p000009MACn.png