Re: LENGTH function and trailing spaces
Posted in 1995
Topics: Data Types & Schema Design, Jobs, Consulting & Announcements
I DONT'T want 'Kirk' and 'Kirk ' to return 7. And I don't want 'Kirk' and 'Kirk ' to return a length of 4 (although I understand that the current LENGTH() function will return 4 in each case. I want to find out the length of the string as stored by the application program. The pubs so I CAN STORE TRAILING blanks in the database for VARCHAR. The question is (still) how can I get the length as stored by the application program via a SQL statement. The answer appears to be that you cannot and that's fine with me. I just wanted to make sure I understood how things worked. Like someone said, if I can't ask that question of the database, then I won't. As to why the blanks were stored there in the first place... that's up to the application and since I'm just a gateway I don't care WHY they are there just that they ARE there. Graeme Sargent (graeme@pyramid.com) wrote: : Kirk Bradley - Mainframe and Integration Technologies (kbradley@130.35.1.6) wrote: : : Right.. it gives their DEFINED lengths not the actual : : lengths (forVARCHAR at least) as stored for a given : : row. It sounds like nobody that uses Informix (at least : : on this forum ;-)) uses length() for this purpose and : : so the fact that you can't do this: : : INSERT INTO VT(VARCOLUMN) VALUES ('Kirk ') : : SELECT * FROM VT WHERE LENGTH(VARCOLUMN) = 7 : : and have the SELECT return that row. : : Correct? : Correct, I guess. : Why would you want either 'Kirk' or 'Kirk ' to be returned as having : length of 7? IMHO most users would ask for length of 4 if they wanted : that row, and that's what Informix would do. : : p.s. I'm getting this info from the 5.0 SQL ref that says : : that TRAILING SPACES ARE STORED in VARCHAR columns. If : : that isn't true then all bets are off I guess. : Only if you put them there. But why would you, except by mistake? : : -- : : 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. -- Kirk Bradley Oracle Corporation Mainframe and Integration Technologies Group