Hi All
I am using DB2 V8.1 on linux.
I have a table as below:
Code:
CREATE TABLE AL_TABLE_EXT (LEN INT, TEXT COLB (2M));
Column LEN is the actual length of TEXT. Now I need to return TEXT with trailing spaces truncated. If LEN = 100, What I need is EXACTLY the result of following:
Code:
SELECT LEN, SUBSTR(TEXT,1,100) AS TEXT FROM AL_TABLE_EXT;
I definitely can not hard-code 100 in my application, so I tried the following:
Code:
SELECT LEN, SUBSTR(TEXT,1,LEN) AS TEXT FROM AL_TABLE_EXT;
The second one did not give me a sub-string, but a whole length of string (with trailing spaces). I also tried function RTRIM. The result was the same.
It seems a simple thing, but I just can't make it exactly as I need.
Could you please advise me? Thank you in advance.