How to concat an integer value with a string in DB2 procedure
30,972
Solution 1
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
Solution 2
No casting is needed - both of the exampples below work:
CONCAT(55555, ' Dollar') as "Test Column"
OR
55555 || ' Dollar' AS "Test Column 2"
Author by
user987880
I want to be a Moderator - one among The Cult Leaders of SO x:{
Updated on February 20, 2020Comments
-
user987880 about 4 years
I have a variable,
price dec(5,0)
. How can I concat a static string "dollar" to that and save as achar(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.