I have a variable, price dec(5,0)
. How can I concat a static string "dollar" to that and save as a char(10)
?
If the price is 55555, the result should be 55555 Dollar and this should be saved as a char(11)
.
How can I do it? I tried casting and just concat using '+', but it was not working.
The concat operator in DB2 is a double pipe, ||
.
Also, you'll need to cast
the decimal value to a char before you can concatenate.
Something like:
select cast(55555 as char(5)) || ' Dollar' from sysibm.sysdummy1
No casting is needed - both of the exampples below work:
CONCAT(55555, ' Dollar') as "Test Column"
OR
55555 || ' Dollar' AS "Test Column 2"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With