Home » SQL & PL/SQL » SQL & PL/SQL » Find out last four digits (Oracle)
Find out last four digits [message #612765] Thu, 24 April 2014 12:02 Go to next message
Shyam.reddy141
Messages: 1
Registered: April 2014
Junior Member
Hi All,

Here is my requirement.Pls help me.

If 4th symbol from the end for COLUMN = '-' then populate COLUMN till symbol '-' Else set to Null.

Please suggest me..Thanks
Re: Find out last four digits [message #612767 is a reply to message #612765] Thu, 24 April 2014 12:07 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Welcome to this forum.


Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/ and please read http://www.orafaq.com/forum/t/174502/102589/

use INSTR() function
http://docs.oracle.com/cd/E16655_01/server.121/e17209/functions087.htm#SQLRF00651
Re: Find out last four digits [message #612774 is a reply to message #612765] Thu, 24 April 2014 12:52 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Something like
update table set col=decode(substr(col,-4,1), '-', substr(col,1,length(col)-4));

Re: Find out last four digits [message #612776 is a reply to message #612774] Thu, 24 April 2014 13:13 Go to previous message
Solomon Yakobson
Messages: 3273
Registered: January 2010
Location: Connecticut, USA
Senior Member
Just for fun with regular expressions:

update table
  set col = regexp_substr(col,'(^.*)-...$',1,1,null,1)
/


SY.
Previous Topic: Get information from LDAP
Next Topic: Comma separated
Goto Forum:
  


Current Time: Thu Apr 25 01:12:45 CDT 2024