Convert BigDecimal to string represenation


#1

Hi,

I have a requirement where I need to copy value from field A to field B. the datatype of field A is bigdecimal and of field B is String. This needs to be done using a query(probably an update query or something like that)
But the Bigdecimal is represented in JSON in below format.
{
scale: 2
unscaledvalue: 7644
}
Example the final value of above is 76.44 but it is represented as scaled and unscaled value.
Can anyone help in how I can achieve this?


#2

TO_STRING(unscaledvalue/power(10,scale))

UPDATE default SET fieldb = TO_STRING(fielda.unscaledvalue/power(10,fielda.scale))
WHERE ......

#3

Thanks vsr1. this solved my issue.