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 > Data Access, Manipulation & Batch Languages > ANSI SQL > Parsing Varchar2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-29-03, 14:36
andavian andavian is offline
Registered User
 
Join Date: Dec 2003
Location: Peoria, AZ
Posts: 3
Parsing Varchar2

I need to parse out some alphabetic characters from a Varchar2 field to leave only the number values. The field values look like this $40-35 or say $40$35.

Is there a sql function or statement to do this. Any help is greatly appreciated.

andavian
Reply With Quote
  #2 (permalink)  
Old 12-29-03, 21:41
arin_am arin_am is offline
Registered User
 
Join Date: Jun 2003
Posts: 34
Re: Parsing Varchar2

select to_number(substr(substr('$40-35' ,2),1,2)), to_number(substr(substr('$40-35' ,2),4,2)) from dual

is your select statement to parse out your 2 dollar amounts.


Quote:
Originally posted by andavian
I need to parse out some alphabetic characters from a Varchar2 field to leave only the number values. The field values look like this $40-35 or say $40$35.

Is there a sql function or statement to do this. Any help is greatly appreciated.

andavian
Reply With Quote
  #3 (permalink)  
Old 01-03-04, 04:49
Rushi Rushi is offline
Registered User
 
Join Date: Jan 2004
Location: India
Posts: 62
Question

This will work only if the position of $ sign is fixed and the length of the string is fixed. Is it So?
__________________
Regards,

Rushi
Reply With Quote
  #4 (permalink)  
Old 01-03-04, 11:12
arin_am arin_am is offline
Registered User
 
Join Date: Jun 2003
Posts: 34
Yes, this is because you have given a fixed length variable and did not mention about how dynamic your VARCHAR would be. This assumes ur variable will be either ''$40-35" or "$40-35" which you have mentioned in your Question.
Quote:
Originally posted by Rushi
This will work only if the position of $ sign is fixed and the length of the string is fixed. Is it So?
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