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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
HeinBloed
Contributor
Contributor

Writing null values into database instead of empty strings

Hi,

 

I try inserting data from a csv file into a postgres database. In the csv file several cells are empty. In my schema the columns are all nullable.

Nevertheless, talend writes empty strings '' into the database instead of null values.

Do you have any idea how I can insert null values?

 

Thanks

Hein

 

0683p000009LrAn.jpg

 

0683p000009Lr7R.jpg

Labels (3)
1 Solution

Accepted Solutions
brama
Contributor III
Contributor III

Hi,

Please try adding one more component tmap in between both the connectors and for that column alone check for empty string if so then set null, something like
Row1. Field==''? null:row1.field.

Let me know if above works.
Thanks,
Ram

View solution in original post

6 Replies
brama
Contributor III
Contributor III

Hi,

Please try adding one more component tmap in between both the connectors and for that column alone check for empty string if so then set null, something like
Row1. Field==''? null:row1.field.

Let me know if above works.
Thanks,
Ram
cterenzi
Specialist
Specialist

Don't use == to compare Strings. Use .equals() or in this case .isempty() instead.
HeinBloed
Contributor
Contributor
Author

Thank you for your quick answers.

I had hoped there was a checkbox or something I missed.

 

But your solution will definitely work.

Anonymous
Not applicable

hello ,

i have one column for monile number and some user not inserted value in that column ..

 

so i wand to replace that value by dot '.'

 

 

 

Thank you

Anonymous
Not applicable

If you are using the suscription version, you can leverage Dynamic schema and do something like that:

 

0683p000009Lyan.pngJob Overview0683p000009Lyax.pngFile extract0683p000009Lyb7.pngFile Schema0683p000009LyK5.pngExtract Dynamic Schema0683p000009LyRh.pngtLog

 

The code in the tJavaRow is

 

Dynamic columns = input_row.dyn; //extract Dynamic
 
//looping on each columns of the row for (int i = 0; i < columns.getColumnCount(); i++) { DynamicMetadata columnMetadata = columns.getColumnMetadata(i); //extracting metadata
//if empty then replace by null if(columnMetadata.getType().equals("id_String") && ((String)columns.getColumnValue(i)).isEmpty()) { columns.setColumnValue(i, null); } }
//replacing the stream row by the new updated one output_row.dyn = columns;

 

 

oballet
Contributor
Contributor

Hi,

it is also possible to use the "tConvertType" component with the "Set empty values to Null before converting" option between your csv file component and your database component.

It saves a lot of time to me, I hope it will be the same for you !

Regards