Re: LENGTH function and trailing spaces
Posted in 1995
Kirk Bradley - Mainframe and Integration Technologies (kbradley@130.35.1.6) wrote: : Maybe I'm not phrasing this right. If I store 10 characters : into a column and 3 of them are trailing spaces and ask : for the LENGTH of the column via SQL I get 7. This is because : LENGTH() will not include the trailing spaces in the returned : value. When I fetch that same column into a 20 byte host variable : (say the database column was defined as 15 bytes) I will (I hope) : get an indication that only 10 bytes were stored into my application : program. The question is, how can I get the number 10 in a SQL : statement? Is it possible? This would represent the size I would : need to allocate for this 1 column/row (let's make it easy and : assume a 1 row 1 column table) in my host program. But if the database column is 15 bytes, why would you want to make your host variable anything other than 15 bytes? There's no way you could know in advance that the column only contains 10 characters, unless you know that they all do, in which case why the heck are you using VARCHAR and padding them with spaces??? : Is that clearer? Is it something anybody ever needs/wants to do? Your words are clearer, but your intent is not. I can't see why anybody would need/want to do it. : -- : Kirk Bradley : Oracle Corporation : Mainframe and Integration Technologies Group -- 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.