pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew McMillan <andrew@catalyst.net.nz>
To: ryanne cruz <ryanne.cruz@up.edu.ph>
Cc: pgsql-php@postgresql.org
Subject: Re: rtrim
Date: 22 Jan 2003 20:31:42 +1300
Message-ID: <1043220702.3118.189.camel@kant.mcmillan.net.nz> (raw)
In-Reply-To: <1043216728.3e2e39585c6f3@mail.up.edu.ph>
References: <1043216728.3e2e39585c6f3@mail.up.edu.ph>

On Wed, 2003-01-22 at 19:25, ryanne cruz wrote:
>  hi list. 
>  
> if there's anyone here who's familiar with teh rtrim function, please i need 
> help. 

It depends on the datatypes in use.

If you use a type like "CHAR(32)" it will always be right-padded with
spaces.  Whereas if you use a type like "TEXT" or "VARCHAR(32)" it will
be stored as you enter it (it may still have some trailling spaces.

Now, when you use the rtrim() function, but insert the result into a
CHAR(N) column, all those spaces will just be stuck straight back on
again.  This is likely to be what is happening in your case.

Regards,
					Andrew.
>  
> i have a table that has a column in it that has data in this format: 
>  
> California, USA 
> Nevada, USA 
> . 
> . 
> . 
>  
> when i use rtrim to erase the ", USA" part, it only sometimes work. a sample 
> result would be: 
>  
> California 
> Nevad 
>  
> my query statement is: 
> update table set name=rtrim(name,', USA'); 
>  
> why is it that it only works sometimes? 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
-- 
---------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St,  Wellington
WEB: http://catalyst.net.nz/         PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201     MOB: +64(21)635-694    OFFICE: +64(4)499-2267
           Survey for nothing with http://survey.net.nz/ 
---------------------------------------------------------------------




view thread (5+ messages)  latest in thread

Message-ID: <1043220702.3118.189.camel@kant.mcmillan.net.nz>
Permalink:  ../1043220702.3118.189.camel@kant.mcmillan.net.nz/
Also on:    postgresql.org/message-id/1043220702.3118.189.camel@kant.mcmillan.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: andrew@catalyst.net.nz, ryanne.cruz@up.edu.ph
  Subject: Re: rtrim
  In-Reply-To: <1043220702.3118.189.camel@kant.mcmillan.net.nz>
  References: <1043216728.3e2e39585c6f3@mail.up.edu.ph> <1043220702.3118.189.camel@kant.mcmillan.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox