Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: LTRIM or TRIM Function

Re: LTRIM or TRIM Function

From: Norman Dunbar <Norman_at_Dunbar-it.co.uk.REMOVETHIS>
Date: Mon, 14 Feb 2005 10:27:52 +0100
Message-ID: <cupu69$8d8$1$8300dec7@news.demon.co.uk>


Paul Izzo wrote:
> I would like to automatically write a users e-mail address based off
> of the first letter of the user's first name combined with the user's
> last name. Ex. Bob Smith = bsmith, Sally Jones = sjones etc...
>
> I don't know which function to use RTRIM or TRIM to take just the first
> letter of the user's first name.
>
> Does anyone know how to go about this?
>

Morning Paul,

LTRIM simply removes spaces from the left end of a string. TRIM simply removes spaces from both ends of a string. RTRIM simply removes spaces from the right end of a string.

I suspect what you need is SUBSTR as in :

email := SUBSTR(LTRIM(first_name),1,1) || trim(last_name);

Of course, you would check for NULLs etc before SUBSTR as in :

first_name := TRIM(first_name);
last_name := TRIM(last_name);

IF (first_name IS NULL) THEN

   handle NULL first name here;
END IF; IF (last_name IS NULL) THEN

   handle NULL last name here;
END IF; email := SUBSTR(first_name,1,1) || last_name;

Cheers,
Norm. Received on Mon Feb 14 2005 - 03:27:52 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US