Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I need to append one character to DB2 column in select Query

SQL
SELECT KEY_TMS FROM TCLT_BILL


i need to append one character to the select query

Suppose the result is

abcd

i need to get as abcd-

i try Concat method its not working
+ symbol is not working in DB2
what to do?. please help
Posted
Comments
ZurdoDev 19-Mar-15 8:26am    
You tried CONCAT(KEY_TMS, '-') ? What happened?

1 solution

If
SELECT CONCAT(KEY_TMS, '-') FROM TCLT_BILL;
does not work then try
SELECT KEY_TMS || '-' FROM TCLT_BILL;
If that also doesn't work then it may be the datatype used for KEY_TMS, try
SELECT CONCAT(CAST(KEY_TMS AS VARCHAR2(50)), '-') FROM TCLT_BILL;
 
Share this answer
 
Comments
jinesh sam 19-Mar-15 8:48am    
for the first one i am getting an error

THE DATA TYPE, LENGTH, OR VALUE OF ARGUMENT 1 OF CONCAT IS INVALID. SQLCODE=-171, SQLSTATE=42815, DRIVER=4.16.53

for the second also same error
and for the 3rd
ILLEGAL SYMBOL "(". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: CCSID ) . FOR. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.16.53
CHill60 19-Mar-15 9:12am    
What datatype is KEY_TMS on the table?
jinesh sam 19-Mar-15 9:30am    
its a spelling mistake in VARCHAR2.
Now i am able to concatentate
Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900