dbTalk Databases Forums  

LTRIM or TRIM Function

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss LTRIM or TRIM Function in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Norman Dunbar
 
Posts: n/a

Default Re: LTRIM or TRIM Function - 02-14-2005 , 03:27 AM






Paul Izzo wrote:
Quote:
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.


Reply With Quote
  #2  
Old   
Paul Izzo
 
Posts: n/a

Default LTRIM or TRIM Function - 02-14-2005 , 03:28 AM






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?


Reply With Quote
  #3  
Old   
its not me
 
Posts: n/a

Default Re: LTRIM or TRIM Function - 02-14-2005 , 04:19 AM



This looks remarkably like homework.

However I personally would use substr.

eg:

select substr(u.firstname,1,1) ||u. lastname
from users_tab u

I suggest you read the manual in particular the sections devoted to
Character Functions Returning Character Values.

http://download-west.oracle.com/docs...unctions2a.htm

On 14 Feb 2005 01:28:45 -0800, "Paul Izzo" <paul.izzo (AT) mosca-ag (DOT) com>
wrote:

Quote:
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?

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com


Reply With Quote
  #4  
Old   
Paul Izzo
 
Posts: n/a

Default Re: LTRIM or TRIM Function - 02-14-2005 , 08:26 AM



I assure you this is not homework. I simply posted an example that is
similiar to what I'm looking for in my database. I phrased my question
in a way that everyone would understand. That way I get the best
replies

Thanks Norman and "it's not me" for your help.


Reply With Quote
  #5  
Old   
DA Morgan
 
Posts: n/a

Default Re: LTRIM or TRIM Function - 02-17-2005 , 10:59 AM



Paul Izzo wrote:

Quote:
I assure you this is not homework. I simply posted an example that is
similiar to what I'm looking for in my database. I phrased my question
in a way that everyone would understand. That way I get the best
replies

Thanks Norman and "it's not me" for your help.
Speaking for myself ... I do not appreciate it when people play games,
and that is how I interpret it, to "get the best replies." If you have
a question ... post it along with the appropriate DDL and DML for us
to work with.

This looks like homework, smells like homework, and if it isn't your
use of TRIM in your example when anyone with 5 weeks of Oracle
experience would have known better ... screams student.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)


Reply With Quote
  #6  
Old   
Paul Izzo
 
Posts: n/a

Default Re: LTRIM or TRIM Function - 02-22-2005 , 07:21 AM



Sorry that my question doesn't comply to you DA Morgen. I was just
looking for a way to create a trigger that would run one a tablespace.
But it's not possible. I don't remember the exact error message but it
had something to do with "mutilated tablespace".

Your replies don't really add any substance to the thread. Do us all
a favor when you think that this is "homework" or too simple for you.
It might not be so easy for someone else. If you don't have anything
constructive to say then keep it to yourself.

I assure you again that this wasn't homework.

P.S. I wasn't able to hand in my final project. I guess I'll drop out
of school and monitor forums as a so called Oracle know it all.


Reply With Quote
  #7  
Old   
DA Morgan
 
Posts: n/a

Default Re: LTRIM or TRIM Function - 02-22-2005 , 01:02 PM



Paul Izzo wrote:

Quote:
Sorry that my question doesn't comply to you DA Morgen. I was just
looking for a way to create a trigger that would run one a tablespace.
But it's not possible. I don't remember the exact error message but it
had something to do with "mutilated tablespace".

Your replies don't really add any substance to the thread. Do us all
a favor when you think that this is "homework" or too simple for you.
It might not be so easy for someone else. If you don't have anything
constructive to say then keep it to yourself.

I assure you again that this wasn't homework.

P.S. I wasn't able to hand in my final project. I guess I'll drop out
of school and monitor forums as a so called Oracle know it all.
The error message was MUTATING not MUTILATED. And I'll stifle the
comment that is on the tip of my tongue.

Do yourself a favor ... provide enough useful and accurate information
for someone to help you if you wish such. But if it was not homework you
might want to seriously consider taking a basic Oracle class.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.