RE: String manipulation
Title: String manipulation I wrote a PL/SQL package with functions you can use for this. Find it at http://www.smdi.com/employee/johnf/list.pks and http://www.smdi.com/employee/johnf/list.pkb. I wrote it so that only the first call parses the string. Subsequent calls use the already parsed pieces. -Original Message-From: Feighery Raymond [mailto:[EMAIL PROTECTED]Sent: Tuesday, January 27, 2004 9:29 AMTo: Multiple recipients of list ORACLE-LSubject: RE: String manipulation select substr(subject,1,instr(subject,'~')-1) first, substr(subject,instr(subject,'~')+1, instr(subject,'~',1,2)-(instr(subject,'~'))-1) second, substr(subject,instr(subject,'~',1,2)+1,length(subject)) third from test_table where test_column=1700455 / Ray -Original Message-From: Stefick Ronald S Contr ESC/HRIDA [mailto:[EMAIL PROTECTED]Sent: Monday, January 26, 2004 11:29 PMTo: Multiple recipients of list ORACLE-LSubject: String manipulation I'm trying to separate a string into 3 values: The string is: mystr1~mystr2~mystr3 Here 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=1700455 The result I get is: mystr1 mystr2~mystr3 mystr3 The result I want is: mystr1 mystr2 Mystr3 TIA, Scott Stefick MILPDS OCP Oracle DBA [EMAIL PROTECTED] 210-565-2540 ___ This email and any attached to it are confidential and intended only for the individual or entity to which it is addressed. If you are not the intended recipient, please let us know by telephoning or emailing the sender. You should also delete the email and any attachment from your systems and should not copy the email or any attachment or disclose their content to any other person or entity. The views expressed here are not necessarily those of Churchill Insurance Group plc or its affiliates or subsidiaries. Thank you. Churchill Insurance Group plc. Company Registration Number - 2280426. England. Registered Office: Churchill Court, Westmoreland Road, Bromley, Kent BR1 1DP.
RE: String manipulation
Title: String manipulation select substr(subject,1,instr(subject,'~')-1) first, substr(subject,instr(subject,'~')+1, instr(subject,'~',1,2)-(instr(subject,'~'))-1) second, substr(subject,instr(subject,'~',1,2)+1,length(subject)) third from test_table where test_column=1700455 / Ray -Original Message-From: Stefick Ronald S Contr ESC/HRIDA [mailto:[EMAIL PROTECTED]Sent: Monday, January 26, 2004 11:29 PMTo: Multiple recipients of list ORACLE-LSubject: String manipulation I'm trying to separate a string into 3 values: The string is: mystr1~mystr2~mystr3 Here 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=1700455 The result I get is: mystr1 mystr2~mystr3 mystr3 The result I want is: mystr1 mystr2 Mystr3 TIA, Scott Stefick MILPDS OCP Oracle DBA [EMAIL PROTECTED] 210-565-2540 ___ This email and any attached to it are confidential and intended only for the individual or entity to which it is addressed. If you are not the intended recipient, please let us know by telephoning or emailing the sender. You should also delete the email and any attachment from your systems and should not copy the email or any attachment or disclose their content to any other person or entity. The views expressed here are not necessarily those of Churchill Insurance Group plc or its affiliates or subsidiaries. Thank you. Churchill Insurance Group plc. Company Registration Number - 2280426. England. Registered Office: Churchill Court, Westmoreland Road, Bromley, Kent BR1 1DP.
Re: String manipulation
On 01/26/2004 06:29:26 PM, Stefick Ronald S Contr ESC/HRIDA wrote: I'm trying to separate a string into 3 values: The string is: mystr1~mystr2~mystr3 There is trivial, non-PL/SQL solution based on the split function. To see more, type "perldoc -f split" and you should see the light. -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Mladen Gogala INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: String manipulation
Title: Message If you have a way to work this out in shell then there is a simpler solution ... $ export VAR='mystr1~mystr2~mystr3'$ echo $VARmystr1~mystr2~mystr3$ echo $VAR | tr '~' '\012'mystr1mystr2mystr3$ HTH, Nikhil -Original Message-From: Stefick Ronald S Contr ESC/HRIDA [mailto:[EMAIL PROTECTED] Sent: Monday, January 26, 2004 3:29 PMTo: Multiple recipients of list ORACLE-LSubject: String manipulation I'm trying to separate a string into 3 values: The string is: mystr1~mystr2~mystr3 Here 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=1700455 The result I get is: mystr1 mystr2~mystr3 mystr3 The result I want is: mystr1 mystr2 Mystr3 TIA, Scott Stefick MILPDS OCP Oracle DBA [EMAIL PROTECTED] 210-565-2540
Re: String manipulation
Here is an example for you. You might want to spend some more time studying the instr() function in the SQL manual to understand how this works. :) define t = 'mystr1~mystr2~mystr3' var t varchar2(30) begin select '&&t' into :t from dual; end; / select substr(:t,1,instr(:t,'~')-1) t1 , substr(:t,instr(:t,'~')+1, instr(:t,'~')-1) t2 , substr(:t,instr(:t,'~',instr(:t,'~')+1)+1, instr(:t,'~')-1) t2 from dual / or the somewhat simpler: select substr(:t,1,instr(:t,'~')-1) t1 , substr(:t,instr(:t,'~')+1, instr(:t,'~')-1) t2 , substr(:t,instr(:t,'~',1,2)+1, instr(:t,'~')-1) t2 from dual / HTH Jared Stefick Ronald S Contr ESC/HRIDA <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 01/26/2004 03:29 PM Please respond to ORACLE-L To: Multiple recipients of list ORACLE-L <[EMAIL PROTECTED]> cc: Subject: String manipulation I'm trying to separate a string into 3 values: The string is: mystr1~mystr2~mystr3 Here 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=1700455 The result I get is: mystr1 mystr2~mystr3 mystr3 The result I want is: mystr1 mystr2 Mystr3 TIA, Scott Stefick MILPDS OCP Oracle DBA [EMAIL PROTECTED] 210-565-2540
RE: String manipulation
Title: Message
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 PMTo: Multiple recipients of list
ORACLE-LSubject: String manipulation
I'm trying to separate a string into 3
values: The string is: mystr1~mystr2~mystr3
Here 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=1700455
The result I get is: mystr1 mystr2~mystr3
mystr3
The result I want is: mystr1 mystr2 Mystr3
TIA,
Scott Stefick MILPDS OCP Oracle DBA [EMAIL PROTECTED] 210-565-2540
