Substr(''mystr1~mystr2~mystr3', 1, 20) => 1 is the position and 20 the
length (not the position).
The "substring" functions return a portion of
string, beginning at character position, substring_length characters
long.
SELECT
substr('mystr1~mystr2~mystr3',1,instr('mystr1~mystr2~mystr3','~')-1)
W_First,
substr('mystr1~mystr2~mystr3',instr('mystr1~mystr2~mystr3','~')+1,
(INSTR('mystr1~mystr2~mystr3', '~',
1,2)-1)-(INSTR('mystr1~mystr2~mystr3','~',1,1)) )
W_SECOND,
substr('mystr1~mystr2~mystr3',instr('mystr1~mystr2~mystr3','~',1,2)+1,length('mystr1~mystr2~mystr3'))
W_THIRD
FROM dual;
-----Original Message-----
From: Stefick Ronald S Contr ESC/HRIDA [mailto:[EMAIL PROTECTED]
Sent: Monday, January 26, 2004 3:29 PM
To: Multiple recipients of list ORACLE-L
Subject: String manipulationI'm trying to separate a string into 3 values:
The string is:
mystr1~mystr2~mystr3Here is the code so far:
1 select substr(subject,1,instr(subject,'~')-1) first,
2 substr(subject,instr(subject,'~')+1, instr(subject,'~',1,2)-1) second,
3 substr(subject,instr(subject,'~',1,2)+1,length(subject))
4 from test_table
5 where test_column=1700455The result I get is:
mystr1
mystr2~mystr3
mystr3The result I want is:
mystr1
mystr2
Mystr3TIA,
Scott Stefick
MILPDS OCP Oracle DBA
[EMAIL PROTECTED]
210-565-2540