If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > select ltrim ('88888',3) from dual;

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-18-03, 17:15
aruneeshsalhotr aruneeshsalhotr is offline
Registered User
 
Join Date: Jul 2003
Location: US
Posts: 314
select ltrim ('88888',3) from dual;

I have a question about doing a trim for first 3 letters of a phone number, so as to extract the area code for a customer.


Is there any function like ltrim which I could possibly use, passing it the start index and end index along with the column name.

Response would be much appreciated.
Thanx and Regards
Aruneesh
Reply With Quote
  #2 (permalink)  
Old 07-18-03, 17:29
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool

Try:

select substr('888-111-2222',1,3) from dual;
Reply With Quote
  #3 (permalink)  
Old 07-18-03, 18:05
aruneeshsalhotr aruneeshsalhotr is offline
Registered User
 
Join Date: Jul 2003
Location: US
Posts: 314
Just skipped my mind

Hi L...DBA
It just skipped my mind about the substr ....

By the way, do u have a document, or any link where the oracle SQL functions are organized in order of functionality.

I know getting a book as an option, but expensive too.
Aruneesh
Reply With Quote
  #4 (permalink)  
Old 07-18-03, 18:11
aruneeshsalhotr aruneeshsalhotr is offline
Registered User
 
Join Date: Jul 2003
Location: US
Posts: 314
Valid zip codes

Hi L...DBA
I had one similar query.
I am creating a list of area codes, and their correspoding zips.

I want to avoid all the invalid zip codes, i mean nothing from Canada should appear. Meaning i just want to use the records which have a 5 digit number as the zip.

Any quickies ?
Thanx and Regards
Aruneesh
Reply With Quote
  #5 (permalink)  
Old 07-18-03, 18:59
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool

Try:

If lenght(zip_code) = 5
And ltrim(translate(zip_code,'0123456789','~'),'~') Is NULL
Then .... 5 digit zip...
Else ... invalid zip ...
End If;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On