Re: Significant spaces - Mailing list pgsql-novice

From mike g
Subject Re: Significant spaces
Date
Msg-id 1091247160.3676.4.camel@localhost.localdomain
Whole thread Raw
In response to Significant spaces  (Steve Tucknott <steve@retsol.co.uk>)
Responses Re: Significant spaces  (Frank Bax <fbax@sympatico.ca>)
List pgsql-novice
The char data type will automatically pad unused positions with space so
it stays fixed at 250.

Varchar will automatically trim any unused positions.

I assume in your code somewhere you are doing a CAST(char column as
varchar).  You can enclose this in a TRIM to remove whitespace at
beginning and end.  TRIM(CAST(char column as varchar))

HTH
On Fri, 2004-07-30 at 07:35, Steve Tucknott wrote:
> PostGreSQL 7.2.4
>
> Can anyone tell me where trailing spaces are significant in CHAR,
> VARCHAR and TEXT fields?
>
> We pass a VARCHAR variable into a 3rd party language product
> 'function' as a CHAR(250). The CHAR(250) field is then used to
> interrogate a table to see if that value exists. If not, a row with
> that value is inserted into the table as a VARCHAR(N). The issue is
> that the value when inserted into the VARCHAR in the table appears to
> carry trailing spaces, so when a subsequent lookup is performed with
> the same value, the value is not 'found' and a further insert occurs.
> The problem appears to disappear if I change the definition of the
> passed parameter to a VARCHAR as well.
> Is this a known issue?
>
>
> Regards,
>
> Steve Tucknott
>
> ReTSol Ltd
>
> DDI: 01903 828769

pgsql-novice by date:

Previous
From: Jeffrey Melloy
Date:
Subject: Re: trying to run a query
Next
From: Frank Bax
Date:
Subject: Re: Significant spaces