Re: LENGTH function and trailing spaces
Posted in 1995
Kirk, To the best of my knowledge trailing blanks are not stored in the database at all. If you really need all 10 characters, make the last one a full stop. Regards, Pete Harris On 9 Apr 1995, Kirk Bradley - Mainframe and Integration Technologies 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. } } Is that clearer? Is it something anybody ever needs/wants to do? } } } } Jack Parker (jparker@hpbs3645.boi.hp.com) wrote: } : > } : > } : > Length is documented as returning the length of a character column, } : > not including the trailing spaces. What method do I use IN SQL to } : > get the REAL length of character column? i.e. what size would be } : > available to a program that fetched that column } } : select collength } : from syscolumns, systables } : where colname = 'xxxxx' } : and tabname = 'yyyyyy' } : and systables.tabid=syscolumns.tabid } } : j. } : _____________________________________________________________________________ } : Jack Parker - Hewlett Packard, BSMC Boise, Idaho, USA } : jparker@hpbs3645.boi.hp.com } : _____________________________________________________________________________ } : "I wave my private parts at your aunties. I burst my pimples at you, } : you tiny empty headed wiper of other peoples bottoms." } : -MP&THG- French Taunter II } : _____________________________________________________________________________ } : Any opinions expressed herein are my own and not those of my employers. } : _____________________________________________________________________________ } } -- } Kirk Bradley } Oracle Corporation } Mainframe and Integration Technologies Group }