#1 2011-07-15 11:11:43

Joe
Member
Registered: 2011-01-07
Posts: 102

deal with null value

Hi all

     In the original table in sql server,column flag was 'NULL', when i extract data from this table via talend ,and write it into delimited file , it values '',blank. How can i keep the column flag the same as 'NULL'? Except using tReplace.




Best Regards!
Joe

Offline

#2 2011-07-15 11:37:37

shong
Talend team
Registered: 2007-08-29
Posts: 10350
Website

Re: deal with null value

Hi Joe
Can you please test it is null or empty on column flag as 'NULL' after you read from table? For example:
tMssqlInput--main--tJavaRow

on tJavaRow:
if(Input_row.columnName==null){
System.out.println("it is null");
}

or


if(Input_row.columnName.equals(""){
System.out.println("it is empty");
}

Let me know your test result!

Best regards
Shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#3 2011-07-15 11:58:10

Joe
Member
Registered: 2011-01-07
Posts: 102

Re: deal with null value

Hi Shong
  Yes, I have tested that already. If I write the data into delimited file first,and then write it to database,it is still empty. If I write it into  table directly from one database to another,it is ok,with the ‘NULL’ Value. But,the table has mass data,and if i process it without delimited file ,it may lead to outofmemory exception and low efficency.

Joe

Offline

#4 2011-07-15 13:02:38

shong
Talend team
Registered: 2007-08-29
Posts: 10350
Website

Re: deal with null value

Hi

Don't know why you use a demited file, but you can convert empty to null on tMap after read it from demilted file, eg:
row1.columnName.equals("")?null:row1.columnName

Best regards
Shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#5 2011-07-15 15:09:19

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1137

Re: deal with null value

There isn't a null value for files, just empty. If you want to include the value null you will have to do it in your tMap.

Offline

#6 2011-07-15 15:58:38

Joe
Member
Registered: 2011-01-07
Posts: 102

Re: deal with null value

Thank you shong and janhess

another problem,If the project that i shall do contains  a lot of data(more than10,000,000 rows),how can i avoid the outofmemory exception? now we take the way of storing the data into files first ,and then reading data from file on disk . It seems to work fine,except a little slow.  Is there any other better ways?
there will be several jobs running parallelly,so we must take care of the memory.


joe

Offline

Board footer

Powered by FluxBB