Xref: alice comp.databases.oracle.server:35813
Path: alice!news-feed.fnsi.net!newsfeed.wli.net!su-news-hub1.bbnplanet.com!news.gtei.net!news.sprintisp.com!sprintisp!not-for-mail
From: david.swanson@sprintranet.com (Dave)
Newsgroups: comp.databases.oracle.server
Subject: Re: Trailing Spaces on VARCHAR2 Data
Date: Sun, 13 Dec 1998 03:50:04 GMT
Lines: 38
Message-ID: <36763922.30635281@nntp.sprintisp.com>
References: <#HnNoUVJ#GA.204@nih2naab.prod2.compuserve.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Newsreader: Forte Agent 1.5/32.451

On Fri, 11 Dec 1998 17:25:27 -0500, Gene Hubert
<110530.717@CompuServe.COM> wrote:

>I'm running Oracle 8.0.3 on NT 4.0.
>

>I occasionally run across data in varchar2 columns that has 
>trailing spaces.  Comparisons on this data will fail without an 
>rtrim or adding the right number of spaces to what is being 
>compared.  Can anyone explain how varchar2 data ends up with 
>trailing spaces?  I thouhgt this was not possbile.
>

>Gene Hubert
>Qualex Inc.
>Durham, NC
>


If you explicitly put the spaces in your insert statement, they will
end up in the string... example:

SQL> create table temp (vvv varchar2(30));

Table created.

SQL> insert into temp values ('asdf         ');

1 row created.

SQL> select '*'||vvv||'*' from temp;

'*'||VVV||'*'
--------------------------------
*asdf         *

If you don't want the data to end up in the database this way, you
could create a trigger to automatically ltrim and rtrim... 
