One Star

[resolved] Data transformation (Postgres boolean -> Oracle NUM) - Migration

Hi,
Language: Java
Database used: Postgres 8.4 / Oracle 10g
I am trying to use tMap component to transform data from boolean type in Postgres to NUM in Oracle (e.g. if column has value false then insert 0)
This is needed as part of Data migration exercise. Some how I did not find way how to do it. I looked through component tConvertType but that does not seem to be helpful either.
Any help on how to achieve this?
Thanks,
Mahendra
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] Data transformation (Postgres boolean -> Oracle NUM) - Migration

Hello
If the data type of output column is BigDecimal, try
row1.columnName==false?new BigDecimal(0) :new BigDecimal(1)

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
6 REPLIES
Community Manager

Re: [resolved] Data transformation (Postgres boolean -> Oracle NUM) - Migration

Hello Mahendra
Try the following expression on tMap: eg:
tPostgresInput--row1--tMap--tOracleOutput
row1.columnName==false?0:1

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Data transformation (Postgres boolean -> Oracle NUM) - Migration

Hi Shong,
I tried the option suggested by you, but this does not work. I have uploaded the screen shot of the same.
The error message coming up after clicking "Test!" button is
"Type mismatch: cannot convert from int to BigDecimal"
Thanks,
Mahendra
Community Manager

Re: [resolved] Data transformation (Postgres boolean -> Oracle NUM) - Migration

Hello
If the data type of output column is BigDecimal, try
row1.columnName==false?new BigDecimal(0) :new BigDecimal(1)

Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Data transformation (Postgres boolean -> Oracle NUM) - Migration

Thanks Shong,
this works.
However I am still getting the message "Exception in thread "main" java.lang.Error: Unresolved compilation problems: ".
Community Manager

Re: [resolved] Data transformation (Postgres boolean -> Oracle NUM) - Migration

Hello
However I am still getting the message "Exception in thread "main" java.lang.Error: Unresolved compilation problems: ".

Does it show the message when you click on 'Test' button? Don't worry, just forget it and I suggest you not to use 'Test' button, it always confuse user eventhough there are not compilation problems in the generated code.
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Data transformation (Postgres boolean -> Oracle NUM) - Migration

Try this using tMap..  row2.Hidden.compareTo(row2.Hidden)