Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Bonjour,
je rencontre un petit problème de conversion de données:
en fait en base MySQL, j'ai un champ "lattitude" type en decimal(15,12) et dans le job le champ est en String.
dans les données j'ai des valeur vide. pour éviter le problème du vide je test s'il est null ou vide ("") de me mettre null sinon la bonne valeur
LattitudeLongitude.lattitude != null ||
LattitudeLongitude.lattitude != ""
? LattitudeLongitude.lattitude : null . Malgrés cela il me ramène l'erreur suivanteData truncation: Incorrect decimal value: '' for column `syncto`.`produit_detail`.`lattitude` at row 1.
J'ai essayé aussi de transformer le String en BigDecimal avec ceci
Relational.ISNULL(LattitudeLongitude.lattitude) ||LattitudeLongitude.lattitude=="" ? new BigDecimal(0) : new BigDecimal(LattitudeLongitude.lattitude).setScale(12,BigDecimal.ROUND_FLOOR)
j'ai même essayé avec du TRIM()
et là j'ai du
java.lang.NumberFormatException
Voici un exemple des données en entrée
***********************Anglais*********************************
Hello,
I have a small data conversion problem:
in fact in MySQL database, I have a "lattitude" type field in decimal(15,12) and in the job the field is in String.
in the data I have empty values. to avoid the problem of the void I test if it is null or empty ("") to put me null otherwise the good value
LattitudeLongitude.lattitude != null || LattitudeLongitude.lattitude != "" ? LattitudeLongitude.lattitude : null . However, it gives me the following error
Data truncation: Incorrect decimal value: '' for column `syncto`.`product_detail`.`lattitude` at row 1.
I also tried to transform the String into BigDecimal with this
Relational.ISNULL(LattitudeLongitude.lattitude) ||LattitudeLongitude.lattitude=="" ? new BigDecimal(0): new BigDecimal(LattitudeLongitude.lattitude).setScale(12,BigDecimal.ROUND_FLOOR)
I even tried with TRIM()
and there I had to
java.lang.NumberFormatException
Here is an example of the input data
Merci par avance de votre aide
Try this instead....
Relational.ISNULL(LattitudeLongitude.lattitude) ||LattitudeLongitude.lattitude.trim().equals("") ? new BigDecimal(0): new BigDecimal(LattitudeLongitude.lattitude).setScale(12,BigDecimal.ROUND_FLOOR)
Your issue here is because you were using "==". This checks to see whether the objects on both sides come from the same memory location. It does not check the value of objects.
Try this instead....
Relational.ISNULL(LattitudeLongitude.lattitude) ||LattitudeLongitude.lattitude.trim().equals("") ? new BigDecimal(0): new BigDecimal(LattitudeLongitude.lattitude).setScale(12,BigDecimal.ROUND_FLOOR)
Your issue here is because you were using "==". This checks to see whether the objects on both sides come from the same memory location. It does not check the value of objects.
that works
thank you very much @rhall