Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SUBSTR and INSTR

Re: SUBSTR and INSTR

From: LECONTE Denis <leconte.d_at_decade.fr>
Date: Thu, 24 Sep 1998 23:09:13 +0200
Message-ID: <6ueci3$8tf$1@peggy.freenet.fr>


Try this:

select
substr(str,1,decode(instr(str,'@')-1,-1,length(str),instr(str,'@')-1)) from dual;

where str is the string to test.



LECONTE Denis
UIN: 5074943 yong a écrit dans le message <360AAF01.DC58A434_at_shell.com>...
|How can I get "yong" using one function (i.e. with no if-block) from
|both "yong_at_shell.com" and "yong"? I want to use substr and instr. For
|example,
|
|select substr('yong_at_shell.com', 1, instr('yong_at_shell.com', '@')-1) from
|dual;
|
|gives me "yong" correctly. But
|
|select substr('yong', 1, instr('yong', '@')-1) from dual;
|
|returns nothing. The instr function in the above select statement won't
|find '@' and it returns 0. So the substr function returns a 0-length
|string. How can I still get "yong" using functions like these or
|replace, translate etc.? Please help. Thanks.
|
|Yong Huang
|Email:yong_at_shell.com
|
Received on Thu Sep 24 1998 - 16:09:13 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US