Re: LENGTH function and trailing spaces
Posted in 1995
Kirk Bradley - Mainframe and Integration Technologies (kbradley@130.35.1.6) wrote: : I now see what I was saying wrong. I kept saying CHAR and I meant : VARCHAR. According to the Guide to SQL: Reference manual (pg 3-18 Data types) : : "The database server does NOT strip a VARCHAR object of any : user-entered trailing blanks, nor does the database server : pad the VARCHAR to the full length of the column." : ok.. so the question is: if I do this: : CREATE TABLE KIRK (VC VARCHAR(100)) : INSERT INTO KIRK VALUES ('KIRK AND 2 TRAILING BLANKS ') : then how do I find out (in a SQL stmt (no 3-GL code)) that : the length stored for that INSERT is 28 cause LENGTH(VC) : will surely return 26 won't it? Yes. You want: SELECT LENGTH(vc||"+")-1 FROM kirk; 'orrible, ain't it. -- graeme -- Disclaimer: The author's opinions are his own, and not necessarily those of Pyramid Technology Ltd. or Pyramid Technology Inc. --------------------------------------------------------------------------- -m------- Graeme Sargent Voice: +44 (0)252 373035 ---mmm----- Senior Database Consultant Fax : +44 (0)252 373135 -----mmmmm--- Pyramid Technology Ltd. Telex: Tell who??? -------mmmmmmm- Farnborough, Hants GU14 7PL Email: graeme@pyra.co.uk --------------------------------------------------------------------------- We have the technology. The tricky bit is learning how to use it.