JDBC producer creating data as empty in database instead of NULL
Hi Team
Â
We were usingÂ
JDBCProducer_01 to load data previously and the load was working fine we were able to see NULL getting loaded instead of empty string but recently we moved to
JDBCQuery_01 and created insert statement but now we see all the NULL are replaced with empty string what can be the fix for same one we need NULL to be loaded into edw table
Page 1 / 1
@akanshajain6793Â ,
In Streamsets ,for the string variable ,if no values from source then by default its value is null and if you are trying insert it into destination table ,it will insert null value.
If you are using jdbc query , then you can use explicitly null value like below.
INSERT INTO EMP VALUES ("123","xxx","Oslo",.12,NULL).
Kindly provide your insert query which is is replacing null value with empty string, so i can check it my data collector and will try to help you on the same.
Â
If its possible if you can validate the null check before inserting data to destination DB then it will very helpful.
it end up inserting empty string is there any other solution to load NULL
@akanshajain6793Â
please let me know if the issue still persist or it has been fixed.
Â
@akanshajain6793Â
You might want to try the approach suggested inÂ
 ?
 if (value != null) {         finalValue = value.replaceAll("'", "''")         record.value key] = "'${finalValue}'"       } else {         record.value key] = 'null'       }
Â
am using above groovy script to handle null or empty data but jdbc insert still fails with below error
Its creating the insert statement where column is coming as null or empty with out single quotes and jbbc stage not able to isnert that
any input?
Â
@Pradeep @BikramÂ
Â
Â
Â
@akanshajain6793Â
The error is from groovy script.
Can I request you to provide me the input details and what data needs to be inserted into DB , then I can help you on it.
I tried with below code and could manage to insert as null string in destination DB .