Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PL/SQL split string, get last value?

Tags:

oracle

plsql

how could one split a string in PL/SQL to get the last value if the pattern look like this? :

'1;2', in this case the value i want would be 2.

Note: the splitter is the character ';' and values are of different length like '1;2 or 123;45678 etc...'

Thanks in advance!

like image 765
SlashJ Avatar asked Nov 29 '22 08:11

SlashJ


1 Answers

SELECT SUBSTR( column_name, 
               INSTR( column_name, ';', -1 ) + 1 )
  FROM table_name

should work. Here is a SQL Fiddle example.

like image 117
Justin Cave Avatar answered Dec 10 '22 03:12

Justin Cave