View previous topic :: View next topic
|
Author |
Message |
roopannamdhari Warnings : 1 New User
Joined: 14 Sep 2006 Posts: 71 Location: Bangalore
|
|
|
|
Hi,
I am having one table1 .
table1
column1 - char(40)
column2 - char(40)
column1 column2
abcd efh
abcd efh
On execution of following query I am getting output as
Select * from table1
OUTPUT:
column1 column2
abcd(36 spaces) efh(37 spaces)
Please let me know how to truncate unused spaces in a column during select statement.
Thanks, |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Roopa,
Try STRIPing the column. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
That is all well and good, but what is the destination field for the column?
you will have to have a host variable large enough to receive the value returned by the select. I doubt that all values contained in these two columns (bytes > spaces) are of the same length. So, eventhough you remove spaces, you will have them again in the host varibale. These columns do not appear to be defined as varchar.
performing the db2 strip is a waste of time. What is your final destination field? Unless you are using PL/1, C or Java as your application, COBOL does not lend itself to variable length fields.
what actually do you need to do? |
|
Back to top |
|
|
roopannamdhari Warnings : 1 New User
Joined: 14 Sep 2006 Posts: 71 Location: Bangalore
|
|
|
|
Hi Murali,
Can u please breif me regarding Striping THE COLUMN
Thanks, |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
as a general point there is no reason to blank_strip a variable
an area large enough to contain the whole string must be provided anyway
th only reasonable ( but as usual it depends ) alternative is to use, IIRC, LTRIM to left align things ( for a quick display )
but to give the best answer the whole requirements must be clear |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
It would be better to focus on the replies that may help with your requirement than the replies that sound like what you believe you want to hear. . .
As has been repeated, STRIP will accomplish little as you still need a variable of proper length. . .
As has also been mentioned, if you explain your requirement (rather than some possible solution), someone here may have suggestions. |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
Why is there an assumption the output is in a program and has a destination field/variable in said program? The way the data was presented, it could be an ad hoc query run against the db and he wants to copy/paste it into another app.
Guess we'll have to see, but it the O/P made it seem like STRIP may do the job. Does DB2 also have the TRIM(Col1) syntax? |
|
Back to top |
|
|
|