View previous topic :: View next topic
|
Author |
Message |
AjmalMohammed
New User
Joined: 02 Jun 2010 Posts: 10 Location: My Cubicle, Hyderabad, India
|
|
|
|
Hi,
How can i concatenate two strings such that trailing spaces(if any) are also included in the end result ?
Code: |
Exec SQL
Select Field1 || Field2 into :Host-Var From TableName where <condition>
from TableName
End-Exec.
|
This query ignores trailing spaces.
Assume Field1 is defined as char(20) holding value 'abc' and Field2 is defined as char(20) with value 'def'. I want host-var to have value of field1 plus 17 blanks then field2 plus 17 blanks.
I think the Substr function might work. I cant experiment as i dont have access to mainframes right now.
Thank you,
Ajmal. |
|
Back to top |
|
|
anshul_gugnani
New User
Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hello Ajmal,
You can cast each column to fixed length column and then concatenate them -
Trying using somthing like -
Code: |
SELECT CAST (Field1 AS CHAR(20)) ||
CAST (Field2 AS CHAR(20))
FROM table
WHERE .... |
Hope this helps..... |
|
Back to top |
|
|
AjmalMohammed
New User
Joined: 02 Jun 2010 Posts: 10 Location: My Cubicle, Hyderabad, India
|
|
|
|
Will this work?
Code: |
SELECT SUBSTR(FIELD1,1,20) || SUBSTR (FIELD2,1,20) FROM TABLE
WHERE <CONDITION>
|
|
|
Back to top |
|
|
anshul_gugnani
New User
Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hello,
Yes this will also work.Will give the same result as above example of CAST. |
|
Back to top |
|
|
|