Fetching characters from a variable string

I have a TicketNo in this format:
00345-4-7-0201
In the above string 02 is a code which can be 01,03, etc. I want to fetch the two characters after second hyphen '-'. substr function is difficult because sometimes the size of the string increases by 1. Is there any SQL function available or a separate function need to be written. If the latter, how to write it?

etc. I want to fetch the two characters after second
hyphen '-'. substr function is difficult becauseor third?
this?
SQL> ed
Wrote file afiedt.buf
  1  with t as
  2  (select '00345-4-7-0201' ticket_no from dual
  3   )
  4*  select substr(ticket_no,instr(ticket_no,'-',1,3)+1,2) from t
SQL> /
SU
02also please post the expected output.
HTH

Similar Messages

  • Look for leftmost 4 characters from a variable

    Dear all,
    I try to get 4 leftmost characters from a variable. Is there any function(such as leftmost(4, a)) in ABAP?
    Thanks in advance

    Hi ..
    We can directly Access the Leftmost 4 chars using:
    DATA : VAR(10) VALUE 'ABCDEFGHIJ'.
    WRITE:/ VAR(4).
    <b>reward if Helpful.</b>

  • Removing number of characters from end of string

    Hi all....
    Dooza very kindly helped me with trimming a string in an
    earlier post, but
    now i want to remove the last four characters from a string.
    I really should know how to do this and will have to do some
    bedtime reading
    :-|
    But, for now, could someone help!
    Thanks
    Andy

    Ah Dooza - Thank You.
    To the rescue again :-D
    You're helping me to see the logic...
    Thanks Again
    Andy
    "Dooza" <[email protected]> wrote in message
    news:gbafel$ra3$[email protected]..
    > Andy wrote:
    >> Hi all....
    >> Dooza very kindly helped me with trimming a string
    in an earlier post,
    >> but now i want to remove the last four characters
    from a string.
    >> I really should know how to do this and will have to
    do some bedtime
    >> reading :-|
    >>
    >> But, for now, could someone help!
    >
    > Hi Andy,
    > Try something like this:
    > <%
    > myStr = "this is my really long string"
    > Response.Write(LEFT(myStr,LEN(myStr) -4))
    > %>
    >
    > Dooza

  • Stop escaped characters from resolving within String class.

    Hello,
    Is it possible to stop escaped characters from resolving within the String class?
    For example, I define a character array,
    char[] c = {'0','\\','n'}
    and I want to create a String based on this exact sequence (0\n). However, when I call the String constructor String(char[]), it resolves the \n sequence into the newline character, creating a String of length 2 not 3.
    I'm not very familiar with the innards of the Java compiler (does "xyz" translate to char[]{'x','y','z'}?), so maybe this is something very basic.
    Does anyone know if there is a flag that can be set somehow before I create a String instance (it appears that no String constructor supports this kind flag)?
    Or perhaps is there a method in the standard Java release that escapes all escape characters in a character array...? I'm curious if there is a simpler way (like a flag), because the method approach seems superfluous.
    Thanks,
    Brien

    What do you mean?char[] c = {'0', '\\', 'n'};
    String s = new String(c);
    System.out.println(s);does give the string 0\n...
    And by the way, it's not the String class that transforms \n to the linefeed character, it is the compiler..

  • Removing Non-numeric characters from Alpha-numeric string

    Hi,
    I have one column in which i have Alpha-numeric data like
    COLUMN X
    +91 (876) 098 6789
    1-567-987-7655
    so on.
    I want to remove Non-numeric characters from above (space,'(',')',+,........)
    i want to write something generic (suppose some function to which i pass the column)
    thanks in advance,
    Mandip

    This variation uses the like operators pattern recognition to remove non alphanumeric characters. It also
    keeps decimals.
    Code Snippet
    CREATE FUNCTION dbo.RemoveChars(@Str varchar(1000))
    RETURNS VARCHAR(1000)
    BEGIN
    declare @NewStr varchar(1000),
    @i int
    set @i = 1
    set @NewStr = ''
    while @i <= len(@str)
    begin
    --grab digits or (| in regex) decimal
    if substring(@str,@i,1) like '%[0-9|.]%'
    begin
    set @NewStr = @NewStr + substring(@str,@i,1)
    end
    else
    begin
    set @NewStr = @NewStr
    end
    set @i = @i + 1
    end
    RETURN Rtrim(Ltrim(@NewStr))
    END
    GO
    Code to validate:
    Code Snippet
    declare @t table(
    TestStr varchar(100)
    insert into @t values ('+91 (8.76) \098 6789');
    insert into @t values ('1-567-987-7655');
    select dbo.RemoveChars(TestStr)
    from @t

  • Removing Non-Ascii Characters from a String

    Hi Everyone,
    I would like to remove all NON-ASCII characters from a large string. For example, I am taking text from websites and would like to remove all the strange arabic and asian characters. How can I accomplish this?
    Thank you in advance.

    I would like to remove all NON-ASCII characters from a large string. I don't know if its a good method but try this:
    str="\u6789gj";
    output="";
    for(char c:str.toCharArray()){
         if((c&(char)0xff00)==0){
              output=output+c;
    System.out.println(output);
    all the strange arabic and asian characters.Don't call them so.... I am an Indian Muslim ;-) ....
    Thanks!

  • Using include with variables (String)?

    Is it possible to include a *.jspf page from a variable (string)?
    I'm currently trying something like this, but I know it isn't quite correct (the PAGE string is already defined):
    <%@ include file="${PAGE}" %>I'm sure this is simple, but I'm pretty new to using JSP (I'm used to normal Java classes and the JSP syntax can be confusing at first...).
    Thanks!

    Ok, you're mixing up your EL expressions with scriptlet variables.
    These things are not the same.
    String PAGE = "pages/home.jspf"; decleares a scriptlet variable called PAGE
    You can normally access it using the scriptlet expression tag like <%= PAGE %>
    ${PAGE} is an EL expression.
    The EL variables are stored as attributes in the page, request, session and application scopes.
    So ${PAGE} will not give you the value of the scriptlet variable Page.
    ${PAGE} is approximately equal to pageContext.findAttribute("PAGE") in java.
    Probably the easiest fix would be to use a scriptlet expression rather than an EL expression.
    <jsp:include page="<%= PAGE %>"/>The better fix would be not to use any scriptlet code at all in your JSP, and maybe just use the JSTL conditional tags.
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <c:set var="PAGE" value="${requestScope.page}"/>
    <c:if test="${empty requestScope.page}">
      <c:set var="PAGE" value="pages/home.jspf"/>
    </c:if>
    <jsp:include page="${PAGE}"/>
    //or
    <c:import url="${PAGE}"/>Cheers,
    evnafets

  • Maximum number of characters for a BPEL string variable

    Hi,
    What is the maximum numbers of characters that a string variable in BPEL process can hold??.
    Is there any document which describes the datatypes in BPEL.
    Regards
    V Kumar

    Trick question - with or without the use of the FM GUI?
    1. Via the FM interface to define a variable, FM will only save the first 1022 characters of your variable definition - if you dare try to enter that many via the GUI dialogue slot.
    2. Importing a variable via MIF, adds virtually any length - I've tested out 2510 characters. HOWEVER, FM will only display the first 1023 characters of this string.
    If you save the file to MIF, you can still see the original length of the variable. The other caveat is that if you touch any of these long variables via the FM GUI (Edit Variables), then FM will truncate it down to 1022 characters - regardless of how you save (binary or MIF).
    FWIW - Klaus Daube lists (see: http://daube.ch/docu/fmaker25.html ):
    Until FM 7.2: up to 255 characters including meta-notations (such as <Default ¶ Font> or \t - this counts as 16 resp. 2 characters). See also note Variables below
    From FM 8.0: up to 2023 Windows Codepage characters or up to 2022 UTF-8 characters
    I'd say that this is not quite correct. You could enter more than 255 prior to FM 7.2 as well, but again the display issue via the GUI kicked in and truncated down to 255. The newer versions only display 1022/1023 but you can enter more than 2510 characters (which in this case is futile anyway).

  • Fetching international characters from Clob

    Hi,
    I am trying to fetch hungarian characters from Clob data. I tried reading the Character Stream returned by Clob.getCharacterStream() in linux and it returns junk characters for those but the same works well with windows. I guess its picking up the platform depended default charset. Is there any way i can get the characters without changing the default charset of the OS ? any other way would be highly appreciated!
    Thanks in advance.

    Hi,
    I am trying to fetch hungarian characters from Clob
    data. I tried reading the Character Stream returned
    by Clob.getCharacterStream() in linux and it returns
    junk characters for those but the same works well
    with windows. Are you printing it to the console window on the OS to determine this?
    Then you are doing it incorrectly. That process of outputing a string requires mapping characters to the console character set.
    The only correct way to do this is to print the numeric representation of each character and see if that is correct. If it is correct then it is not a JDBC/driver problem. If it is not correct then it is a JDBC/driver problem.

  • Strip Characters from String?

    Hi,
    How can I strip off some characters from the end of a string?
    I am not very good at regular expressions but perhaps I may not
    need one? Here is the data
    first_name_510
    last_name_2267
    I need a function that will strip off everything from the
    right including the underscore. I should be left with the below:
    first_name
    last_name
    Any help highly appreciated
    Regards

    if it is always an underscore, and always the last one, this
    should do
    the trick:
    #left(string, len(string)-len(listlast(string, "_"))-1)#
    string is assumed to be the variable holding your text
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

  • Extract 2 characters from string

    Hello,
    Can anyone help to create a formula to extract 2 characters from the left of "pp" in a field using CR XI?
    Field = {MainEstimateDetails.JobDescription} (string)
    Sample string details:
    "Annual Report 96pp & Cover 12345"  - want to be able to show only 96 (from 96pp)
    "CTP A4 4pp" - want to be able to show only 4 (from 4pp)
    The string length is variable and the "pp" will be in different places each time.
    It is probably very simple, but I cannot get it

    Hi, 
    You can use the InStr function for this.  InStr returns the position of the string your are looking for. 
    NumberVar myPosition;
    If InStr ({MainEstimateDetails.JobDescription}, "pp") > 0 Then
        myPosition := InStr ({MainEstimateDetails.JobDescription}, "pp")
    Else myPosition := 0;
    If myPosition <> 0 Then
        {MainEstimateDetails.JobDescription} [(myPosition - 2) To (myPosition - 1)]
    Else "";
    This is a bit longer than I would normally do it but... I use Instr to check if the field has "pp" in it.  If it does it will return the character position in the field and I pass that to my variable myPosition. 
    If myPosition has a value then it parses out the two characters before "pp". 
    Good luck,
    Brian

  • Use a String to get data from a variable?

    Hi, I've got a major problem, I need to get data (int []) from a variable, using a String with the name of the variable..
    Does anyone know if this is possible?
    public class Commands {
        private static final int[] deploy_1 = {64,37,73,1};
        private static final int[] deploy_2 = {4,167,6,51};
        /** Creates a new instance of Commands */
        public Commands() {
        public int[] get(String name)
    // what code here?
    }I should be getting the data with
    int[] command = Commands.get("deploy_1");
    or something like that...
    Please help me!
    FYI, a hashtable is not a option!
    Many thanks, Vikko

    java.lang.NoSuchFieldException: deploy_1
    at java.lang.Class.getField(Class.java:1507)
    at dumb_commandstest.Commands.get(Commands.java:30)
    at dumb_commandstest.Main.getData(Main.java:36)
    at dumb_commandstest.Main.<init>(Main.java:21)
    at dumb_commandstest.Main.main(Main.java:28)
    Any ideas why I get a NoSuchFieldException?
    deploy_1 does exist.

  • Removing non english characters from my string input source

    Guys,
    I have problem where I need to remove all non english (Latin) characters from a string, what should be the right API to do this?
    One I'm using right now is:
    s.replaceAll("[^\\x00-\\x7F]", "");//s is a string having chinese characters.
    I'm looking for a standard Solution for such problems, where we deal with multiple lingual characters.
    TIA
    Nitin

    Nitin_tiwari wrote:
    I have a string which has Chinese as well as Japanese characters, and I only want to remove only Chinese characters.
    What's the best way to go about it?Oh, I see!
    Well, the problem here is that Strings don't have any information on the language. What you can get out of a String (provided you have the necessary data from the Unicode standard) is the script that is used.
    A script can be used for multiple languages (for example English and German use mostly the same script, even if there are a few characters that are only used in German).
    A language can use multiple scripts (for example Japanese uses Kanji, Hiragana and Katakana).
    And if I remember correctly, then Japanese and Chinese texts share some characters on the Unicode plane (I might be wrong, 'though, since I speak/write neither of those languages).
    These two facts make these kinds of detections hard to do. In some cases they are easy (separating latin-script texts from anything else) in others it may be much tougher or even impossible (Chinese/Japanese).

  • While trying to invoke the method java.lang.String.length() of an object loaded from local variable 'payload'

    Hi,
    Our PI is getting data from WebSphere MQ and pushing to SAP. So our sender CC is JMS and receiver is Proxy. Our PI version is 7.31.
    Our connectivity between the MQ is success but getting the following error while trying to read the payload.
    Text: TxManagerFilter received an error:
    [EXCEPTION]
    java.lang.NullPointerException: while trying to invoke the method java.lang.String.length() of an object loaded from local variable 'payload'
           at com.sap.aii.adapter.jms.core.channel.filter.ConvertJmsMessageToBinaryFilter.filter(ConvertJmsMessageToBinaryFilter.java:73)
           at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:204)
           at com.sap.aii.adapter.jms.core.channel.filter.InboundDuplicateCheckFilter.filter(InboundDuplicateCheckFilter.java:348)
           at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:204)
    I have searched SDN but couldn't fix it. Please provide your suggestion.
    With Regards
    Amarnath M

    Hi Amarnath,
    Where exactly you are getting this error?
    If you are getting at JMS Sender communication channel, try to stop and start the JMS communication channel and see the status, also use XPI Inspector to get the exact error log.
    for reference follow below blogs:
    Michal's PI tips: ActiveMQ - JMS - topics with SAP PI 7.3
    Michal's PI tips: XPI inspector - help OSS and yourself
    XPI Inspector

  • Approval task SP09: Evaluation of approvalid failed with Exception: while trying to invoke the method java.lang.String.length() of an object loaded from local variable 'aValue'

    Hi everyone,
    I just installed SP09 and i was testing the solution. And I found a problem with the approvals tasks.
    I configured a simple ROLE approval task for validate add event. And when the runtime executes the task, the dispatcher log shows a error:
    ERROR: Evaluation of approvalid failed with Exception: while trying to invoke the method java.lang.String.length() of an object loaded from local variable 'aValue'
    And the notifications configured on approval task does not start either.
    The approval goes to the ToDO tab of the approver, but when approved, also the ROLE stays in "Pending" State.
    I downgraded the Runtime components to SP08 to test, and the approvals tasks works correctly.
    Has anyone passed trough this situation in SP09?
    I think there is an issue with the runtime components delivered with this initial package of SP09.
    Suggestions?

    Hi Kelvin,2016081
    The issue is caused by a program error in the Dispatcher component. A fix will be provided in Identity Management SP9 Patch 2 for the Runtime component. I expect the patch will be delivered within a week or two.
    For more info about the issue and the patch please refer to SAPNote 2016081.
    @Michael Penn - I might be able to assist if you provide the ticket number
    Cheers,
    Kristiyan
    IdM Development

Maybe you are looking for

  • I gt problem in createImage method, Please Help Me!

    This part of code is from Ticker.Class: public void createParams()      {//tickerTape.x = 900;           //tickerTape.y = 40;           int width = getSize().width;           //System.out.println("getSize().width "+getSize().width);           int hei

  • Why can't I download photos from my harddrive in PSE Organizer 8?

    I've tried 3 different times to download my photos in PSE Organizer 8 from my harddrive.  Each time I tried a smaller group.  I just upgraded from Elements 4 and I was impressed with some of the features with the organizer and decided to try and use

  • Need get a distribution license of Flash Player for Swfkit

    hi , i use swfkit 3.5 for create standlone desktop Flash swfkit have a Flash_player_activex version 9 that will be install if the system not reconize flash player on windows . but now i really need to ugrade and use version 11 of flash player i dont

  • Photos disappeared in migration to new Mac

    I've learned a lot from reading this already but don't see my specific problem so here goes. My old iBook was dying so several months ago I bought a new one and moved everything over to the new machine using FireWire. However, iPhoto 6.06 on the new

  • Keyboard doesn't respond at login window... works in Single User mode

    I have a G4 xServe (server 10.3) that won't accept keyboard input at login window, but the same keyboard, usb port, works fine when I'm booted into Single User Mode. Booting into Single User mode, something interesting gets posted during boot: "Apple