Handling Strings?

I'm currently working with a database, in which some primary
keys are varchars. I'm supposed to make an application that creates
an "automatic" primary key for each new register, currently for
instance, if the max(pk) is 100, the new one is 101. My question
is, how to handle strings in a way in which if max(pk) is abx, I
can do abx +1 to get aby - or similar. Any comments?

Here is how I might approach the problem:
1. See if the last set of values are numbers using a Regular
Expression to look at the end of the string for numbers
2 If so, strip out those numbers into a variable and the
characters into a second variable
2.1 Add 1 to the variable.
2.2. Join the second variable with new first variable to get
your new number
3. If there are no numbers at the end, then append 1 to the
end.

Similar Messages

  • WSDL - s:any handling & string to structure

    Hi,
    We have a WSDL supplied to us by a partner, generated by Visual Studio. Helpfully it doesnt actually declare or include the XSD structures within the Type definitions.  There are 2 scenarios (examples below) that I need to deal with.
    1) They declare the xml as a string so this will need to be converted to a structure and passed to an appropriate MI. (in the BPE so that errors are handled).
    2) They declare the structure as <s:any /> which is valid WSDL but not so helpful to XI as it doesnt know what to do with it. 
    If I define TheRequest and TheResponse from the WSDL in a Mapping then I can only see as far as TheRequestXML and TheResponseXML, no deeper.  I can see no Node operation to map 1 field to a whole structure.
    It would be possible to do this in XSLT or a Java Mapping but that seems like the wrong way of going about this as it cant be that uncommon an occurance.
    The XSD does not have any visibility of the methods in the WSDL (TheRequest / TheRequestXML etc). 
    I can work around this by hacking the WSDL to include & use the types in the XSD explicitly, but that again seems wrong.
    Namespace is defined
    xmlns:s="http://www.w3.org/2001/XMLSchema"
    <wsdl:types>
        <s:schema elementFormDefault="qualified" targetNamespace="http://www.somewhere.com/">
          <s:element name="TheRequest">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="TheRequestXML" type="s:string" />
              </s:sequence>
            </s:complexType>
          </s:element>
          <s:element name="TheResponse">
            <s:complexType>
              <s:sequence>
                <s:element minOccurs="0" maxOccurs="1" name="TheResponseXML">
                  <s:complexType mixed="true">
                    <s:sequence>
                      <s:any />
                    </s:sequence>
                  </s:complexType>
                </s:element>
              </s:sequence>
            </s:complexType>
          </s:element>
        </s:schema>
      </wsdl:types>
    Thanks
    James

    The message structure is defined in 2 parts:
    WSDL
      +--> XSD
    When someone calls the Soap Sender and sends over some data (a SOAP message) and this contains a structure like:
    <some method>
    <some top level soap / wsdl node>
    .... importing or including
      <some top level xsd node>
       <rest of structure>
    The maps then map any of the above nodes as the MI's use the top level soap methods.  The problem is that unless the WSDL explicitly defines the Type from the XSD (rather than using s:any or just sticking it in a string) then the fields are not visible to any maps.
    I agree it's not ideal, but hey I didnt design the WSDL
    I just want to know how to handle these 2 scenarios and map the s:any and string to the (known) XSD structure so it may be used as normal in a further map.
    Cheers
    James

  • Most efficient way to handle Strings?

    I've heard that Strings are immutable, so you should use StringBuffers. For example, lets say you have an array of Strings called testArray...
    String matchMe = "";
    for (int i = 0 ; i < testArray.length ; i++)
        matchMe = resultOfSomeExpression;
        if (testArray.equals(matchMe))
    doSomeOperation;
    ...matchMe = resultOfSomeExpression will produce a new String object every time you go through the loop. So I've heard you're supposed to make matchMe a StringBuffer and use StringBuffer.replace() to reset it. That seems really cumbersome to me. I've been using StringBuffers as much as possible, but it requires a lot more code that just using Strings. What do other people do? What's the best procedure?
    Ethan

    The best procedure is what works best for you - but, what I suggest is that you use a String object when you don't plan on modifying it, and that you use a StringBuffer object if you're going to modify a sequence of characters or will construct strings dynamically. The rationale behind this is that behind the scene the compiler uses StringBuffer to handle concantenation of strings.

  • Need help in handling string of characters

    Hi,
    I am trying to scan string and separate different text based on business logic. For example:
    String = 'My bus comes at 999 F Street at 8 am'
    Now I need to scan the string and break the sentence into multiple words like:
    - First occurrence of number which is 999 goes into var1 variable.
    - Last occurrence of number which is 8 goes into var2 variable.
    I am wondering if this can be achieve with regular expression of any oracle internal function.
    Thanks,
    Edited by: skas on Jun 6, 2013 10:34 PM

    nkvkashyap wrote:
    or you can even try like this...
    with data(str) as
    (select 'My bus comes at 999 F Street at 8 am' from dual),
    data1 as
    (select regexp_replace(str, '[^[:digit:]]+', ' ') a from data)
    select regexp_substr(a,'[^ ]+',1,1) var1,regexp_substr(a,'[^ ]+',1,2) var2 from data1;
    Output:
    var1         var2
    999     8
    No need to make this complicated ;)
    SQL> with data(str) as
      2  (
      3   select 'My bus comes at 999 F Street at 8 am'
      4   from dual
      5  )
      6  select     regexp_sUBsTR(str, '\d+') VAR1,
      7     regexp_sUBSTR(str, '\d+',1,2) VAR2
      8  from data;
    VAR V
    999 8Edited by: jeneesh on Jun 7, 2013 11:11 AM
    Missed David's post.. This is the same as his post..

  • Problems in Handling String Variables with Pro*C

    I have a Pro*C program that select one record from a table. Although I don't have any NULL values in this record, I got the following error:
    ORA-01405: fetched column value is NULL.
    This problem only accurs when I try to retrieve[b] characters. Everything works fine when I handle numbers.
    I also tried to use indicators with the output value from the query. Another error was returned:
    ORA-03106: fatal two-task communication protocol error.
    I am not sure wheather the problem is from my program or some configuration of the environment or the client.
    The database (Oracle 9i) is in a remote machine, and I am using Oracle Client (9i) in my machine running Tru64 OS.
    The code that I am using is as follows:
    EXEC SQL BEGIN DECLARE SECTION;
    int db_classId;
    char db_neId[101];
    EXEC SQL END DECLARE SECTION;
    EXEC SQL SELECT class_id, ne_id INTO :db_classId, :db_neId
    FROM NE_ROUTE WHERE ne_id like 'BA%';
    Can anyone help on this issue? Is it something to do with NLS_LANG parameter?
    I just want to note down that all queries work fine with SQL Plus

    Hi,
    I used different select statements as you suggested, but I still get the same error. I also changed the statement to make sure it doesn't return a NULL value.
    I tried the following cases
    1. EXEC SQL SELECT 'name' INTO :db_neId FROM DUAL;
    and I get >> ORA-01405: fetched column value is NULL.
    2. EXEC SQL SELECT NVL('name','name2') INTO :db_neId FROM DUAL;
    and I get >> ORA-01405: fetched column value is NULL.
    3. EXEC SQL SELECT 'name' INTO :db_neId :ind_ne FROM DUAL;
    and I get >> ORA-03106: fatal two-task communication protocol error.
    I haven't try to change the precompiler options yet. The program is very simple as I only use to test the connection with the database. I am just trying to retieve any character from the database.
    Any suggestions?

  • How does Java Handle String Literals Setting to Null for Identical Values ?

    Suppose,
    String s1="Java";
    String s2="Java";
    Now if i am not wrong only one value(bit pattern) "Java" exists in the heap and both s1 and s2 are pointing to it.
    If i set s1 to null,
    s1=null;
    Won't s2 be affected (it is not getting affected actually..)
    What could be the cause for this ?
    Thanks in Advance.

    amtidumpti wrote:
    So is it something like ....
    Variable         Memory Address   Value
    s1                      0234234           "Java"
    s2                      0234235           "Java"
    is s1 is set to null :
    Variable         Memory Address   Value
    s1                      0234234           null
    s2                      0234235           "Java"
    No. In your model here, a variable's value is a String object. It's as if your entire house exists on my s1 paper, and an exact duplicate house with all the same contents exists on my s2 paper. In Java, no variable or expression ever holds an object. No value is ever an object.
    It's more like this:
    Variable         Memory Address         Value
    s1                      0234234           11223344
    s2                      0234235           11223344
    is s1 is set to null :
    Variable         Memory Address         Value
    s1                      0234234           null
    s2                      0234235           11223344and 11223344 is, roughly speaking, the "address" where the String object holding "Java" is stored.
    And in both your model and mine, "Memory Address" is not the address that the variable holds. Rather, it is the address that corresponds to what we humans have named s1 and s2 for our convenience.
    Edited by: jverd on Apr 10, 2009 11:43 AM

  • Using Convert to handle NULL values for empty Strings ""

    After having had the problem with null values not being returned as nulls and reading some suggestion solution I added a converter to my application.
      <converter>
        <converter-id>NullStringConverter</converter-id>
        <converter-for-class>java.lang.String</converter-for-class>
        <converter-class>com.j2anywhere.addressbookserver.web.NullStringConverter</converter-class>
      </converter>
    ...I then implemented it as follows:
      public String getAsString(FacesContext context, UIComponent component, Object object)
        System.out.println("Converting to String : "+object);
        if (object == null)
          System.out.println("READING null");
          return "NULL";
        else
          if (((String)object).equals(""))
            System.out.println("READING null (Second Check)");
            return null;       
          else
            return object.toString();
      public Object getAsObject(FacesContext context, UIComponent component, String value)
        System.out.println("Converting to Object: "+value+"-"+value.trim().length());
        if (value.trim().length()==0 || value.equals("NULL"))
          System.out.println("WRITING null");
          return null;
        else
          return value.toUpperCase();
    ...I can see that it is converting my values, however the object to which the inputText fields are bound are still set to empty strings ""
    <h:inputText size="50" value="#{addressBookController.contactDetails.information}" converter="NullStringConverter"/>Also when reading the object values any nulls are already converted to empty strings before ariving at the converter. It seems that there is a default converter handling string values.
    How can I resolve this problem as set nulls when the input value is an empty string other then checking every string in my class individually. I would really hate to pollute my object model with empty string tests.
    Thanks in advance
    Edited by: j2anywhere.com on Oct 19, 2008 9:06 AM

    I changed my converter as suggested :
      public Object getAsObject(FacesContext context, UIComponent component, String value)
        if (value == null || value.trim().length() == 0)
          if (component instanceof EditableValueHolder)
            System.out.println("SUBMITTED VALUE SET TO NULL");
            ((EditableValueHolder) component).setSubmittedValue(null);
          else
            System.out.println("COMPONENT :"+component.getClass().getName());
          System.out.println("Converting to Object: " + value + "< to " + null);
          return null;
        System.out.println("Converting to Object: " + value + "< to " + value);
        return value;
      }which produces the following output :
    SUBMITTED VALUE SET TO NULL
    Converting to Object: < to null
    Info : The INFO line however comes from my controller object where I print out the set value :
    package com.simple;
    import java.util.ArrayList;
    import java.util.List;
    public class Controller
      private String information;
      /** Creates a new instance of Controller */
      public Controller()
        System.out.println("Createing Controller");
        information = "Constructed";
      public String process()
        System.out.println("Info : "+getInformation());
        return "processed";
      public String reset()
        setInformation("Re-Constructed");
        System.out.println("Info : "+getInformation());
        return "processed";
      public String setNull()
        setInformation(null);
        System.out.println("Info : "+getInformation());
        return "processed";
      public String getInformation()
        return information;
      public void setInformation(String information)
        this.information = information;
    }I also changes my JSP / JSF page a little. Here is the updated version
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%--
        This file is an entry point for JavaServer Faces application.
    --%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
      </head>
      <body>
        <f:view>
          <h:form>
            <h:inputText id="value" value="#{Controller.information}"/>
            <hr/>
            <h:commandLink action="#{Controller.process}">
              <h:outputText id="clicker" value="Process"/>
            </h:commandLink>             
            <hr/>
            <h:commandLink action="#{Controller.reset}">
              <h:outputText id="reset" value="Reset"/>
            </h:commandLink>             
            <hr/>
            <h:commandLink action="#{Controller.setNull}">
              <h:outputText id="setNull" value="Set Null"/>
            </h:commandLink>             
          </h:form>
        </f:view>
      </body>
    </html>The converter is declared for the String class in the faces configuration file. From the log message is appears to be invoked, however the object is not set to null.
    I tested this with JSF 1.2_04-b20-p03 as well as 1.2_09-b02-FCS.
    any other suggestions what could be causing this.

  • Unable to handle the java String

    Hi,
    I am unable to handle string object(character array) using the negative byte values.
    for eg: if i am forming a String Object using byte array which is having negative values(like -127,-118) i am not getting correct ascii value instead i am getting '?' .
    Put some light on this.
    Thanx in advance.

    "-127" -> as an unsigned byte: 129 -> ASCII only
    ranges up to 128Add 256 to your negative byte values. It will give correct characters for ur generated string.

  • Null String and Empty String problem

    Hello everyone,
    since i am totally new in JSP, i am getting problem in handling strings.
    Suppose i have a variable users = ""; then
    I want to ask when to use:
    if (users.equals(""))
    and
    if(users == "")
    in my code, variable users has value "regional" for regional users.
    and i am checking this code as:
    if (users.equals{"regional")) {
    out.print ("I am inside code");
    at that time, the code is throwing error (run time error)
    and when i changed the code as:
    if (users == "regional") {
    out.print ("I am inside code");
    this time, the code is not generating error but the part message "I am inside code " is not displaying. The code do not inserts inside the if condition
    I hope u understand my problem. Can anybody help me out with this.

    This has basically nothing to do with JSP, but with basic Java knowledge.
    When using the '==' operator to compare Objects (yes, String is actually a subclass of Object), then it will look if they are of the same reference. Using the '==' operator to compare primitive datatypes (int, boolean, char, etc) will look if they have the same value.
    That is why the Object class has the equals() method to give the ability compare with another objects. And you can only invoke it when the Object is actually instantiated. So if it is not null.
    if (string != null && string.equals("somevalue")) {
    // or
    if ("somevalue".equals(string)) {
    }should work.
    Edit rym82: this will not throw a NPE, but an ordinary compilation error ;)
    Message was edited by:
    BalusC

  • How to parse xml string using JSTL

    Suppose this is my string:-----
    <books>
    <book>
    <title id=1>Book Title A</title>
    <author>A. B. C.</author>
    <price>17.95</price>
    </book>
    <book>
    <title id=2>Book Title B</title>
    <author>X. Y. Z.</author>
    <price>24.99</price>
    </book>
    </books>
    and I want to read title id = 1 then, how to parse it, I found tutorials regarding parsing simple xml document but how to parse attributes of a given XML

    But both of them either parse a file or data from an input source. I don't think they handle strings.An InputSource can be constructed with a Reader as input. One useful subclass of Reader is StringReader, so you'd use something likeDocument doc = documentBuilder.parse(new InputSource(new StringReader(myXMLString)));

  • How to parse xml string

    Hi! I'm having problems parsing an xml string. I've done DOM and SAX parsing before. But both of them either parse a file or data from an input source. I don't think they handle strings. I also don't want to write the string into a file just so I can use DOM or SAX.
    I'm looking for something where I could simply do:
    Document doc = documentBuilder.parse( myXMLString );
    So the heirarchy is automatically established for me. Then I could just do
    Element elem = doc.getElement();
    String name = elem.getTagName();
    These aren't the only methods I would want to use. Again, my main problem is how to parse xml if it is stored in a string, not a file, nor comming from a stream.
    thanks!

    But both of them either parse a file or data from an input source. I don't think they handle strings.An InputSource can be constructed with a Reader as input. One useful subclass of Reader is StringReader, so you'd use something likeDocument doc = documentBuilder.parse(new InputSource(new StringReader(myXMLString)));

  • How to handle an Exception in GP through webdunpro

    Hi,
    How to handle exception in WebDynpro GP callable objects.
    I created exception parameter in getdescription() method like
    IGPExceptionInfo processExc1 = technicalDescription.addProcessException("USER_NOT_FOUND");
      processExc1.setNameKey("USER_KEY");
      processExc1.setDescriptionKey("USER_DESCRIPTION_KEY");
      processExc1.setFatal(true);
    In my Process I have 2 levels, In block level i am able to see the above created exception using exception tab.
    I have created an action with same callable object mapped, this action is mapped to exception handler & selected an repeat option from dropdown.
    If any exception occurs in execute method(like UMException) how to call an  handler from coding. I tried this code to call a handler
    String localizedMessage =textAccessor.getText("USER_NOT_FOUND");
      wdThis.wdFireEventTechnicalException(new GPTechnicalCallableObjectException(logger,localizedMessage,e));
    this is not working...
    Can any one please bring me an Solution.
    Thanks in advance.
    Regards
    ThenMalar

    Hi Shikhil
    Thanks for your reply
    Please have a look below for exceptions which i am getting in GP and let me know how to handle these exceptions.
    1) "Activity could not be read"
    2) "Action has been stopped"
    3) error while processing the item can not be displayed
    if you give any idea/clue how to handle these exceptions then it would be great help to me
    Thanks
    Sunil

  • Handling parameters when using BI Server as a Data Source

    Hi,
    Following an upgrade of our BI Publisher 10g content to 11g I've come across a syntax issue with 11g when it comes to the handling of parameters in BI Server Data Sets.
    Under 10g, the documentation stated the following:
    +"If your data source is the Oracle BI Server, use the following macro to handle the null:+
    +{$ if ${sYear}='*'$}+
    +{$elsif ${sYear}='2000' $}+
    +where Year = :sYear+
    +{$else $}+
    +where Year = :sYear+
    +{$endif$} "+
    http://docs.oracle.com/cd/E10415_01/doc/bi.1013/e12187/T518230T518233.htm
    Under 11g it does not seem to allow the use of macros defined in Data Sets and raises the following error when saving the query:
    +"java.io.IOException: prepare query failed[nQSError: 43113] Message returned from OBIS. [nQSError: 27002] Near <$>: Syntax error [nQSError: 26012] ."+
    If macros are no longer supported, what is the best approach to handle null value parameters (caused by all choices / nothing being selected)
    as they need to be defined in the Data Set WHERE CLAUSE?
    I've tried a rather clunky CASE WHEN statement which handles string parameters fine, but dates are another thing as null values are returned as 'null' text which causes TYPE mismatch errors.
    Hopefully there is an elegant way to handle this in 11g (the 10g macros were very straight forward when dealing with BI Server)
    Many Thanks

    If what you are saying is true then I would highly recommend open a ticket with Oracle Support.
    They should provide and alternative for handling NULLS in 11g.
    regards
    Jorge

  • String substitution question

    Hello there,
    I have some SQL statements, such as:
    CREATE Table1 ( column1 INTEGER NOT NULL, column2 VARCHAR(20), column3 VARCHAR(30) )
    INSERT INTO Table1 (column1, column2, column3) VALUES (?, ?, ?)where I want to put the names of the columns in square brackets, i.e. substitute the column1, column2 and column3 by [column1], [column2] and [column3], respectively.
    For the INSERT case, I have noticed that one should handle strings occuring after an opening bracket "(" until a comma and after a comma "," until another comma or a closing bracket except the case when there is a ? before the comma, but the CREATE case is trickier...
    Could you please help me out with this? Thanks in advance.

    Thank you very much for your answers!
    I would like to once again thank Monica for her friendly attitude and her willingness to help! I have not followed all of her suggestions exactly, but they have indeed helped me much.
    I am glad to see that the SUN guys have fixed the forum formatting, so that you can read my solution easier. Any improvement suggestions or comments are, as always, most welcome.
    // Sample solution for the CREATE statement:
    String cStmt = "CREATE Table1 (column1 INTEGER NOT NULL, column2 VARCHAR(20), column3 VARCHAR(30))";
    int fw = 0; String new_cStmt = "";
    new_cStmt = cStmt.substring(fw, (fw=cStmt.indexOf("("))) + "( [" +
    cStmt.substring( fw+1, (fw=cStmt.indexOf(' ', fw+1)) ) + "] " +
    cStmt.substring( fw+1, (fw=cStmt.indexOf(",", fw+1)) );
    while(cStmt.lastIndexOf(",") > fw)
      new_cStmt += ", [" + cStmt.substring( fw+2, (fw=cStmt.indexOf(' ', fw+2)) ) + "] " +
    cStmt.substring( fw+1, (fw=cStmt.indexOf(",", fw+2)) );
    new_cStmt += ", [" + cStmt.substring( fw+2, (fw=cStmt.indexOf(' ', fw+2)) ) + "] " + cStmt.substring(fw+1);
    System.out.println(">> New CREATE statement: " + new_cStmt + " <<");
    // Sample solution for the INSERT statement:
    String iStmt = "INSERT INTO Table1 (column1, column2, column3) VALUES (?, ?, ?)";
    int fw = 0; String new_iStmt = "";
    new_iStmt = iStmt.substring(fw, (fw=iStmt.indexOf("("))) + "( [" + iStmt.substring( fw+1, (fw=iStmt.indexOf(",")) ) + "], ";
    // Relevant examination till first closing bracket in the INSERT statement
    while(iStmt.lastIndexOf("VALUES") > iStmt.indexOf(",", fw+1))
      new_iStmt += "[" + iStmt.substring( fw+2, (fw=iStmt.indexOf(",", fw+1)) ) + "], ";
    new_iStmt += "[" + iStmt.substring(fw+2, (fw=iStmt.indexOf(")"))) + "] )" + iStmt.substring(fw+1);
    System.out.println(">> New INSERT statement: " + new_iStmt + " <<");

  • Limit string-length in Reporting Data Source

    Hello,
    we want to report some attributes to the BI. For this we use the standard reporting activity in the BPM. After we done a lot of configuration on the CE and the BI we achieved to connect the two systems. All attributes are passed correctly to the BI and now we have a problem with the string-length we pass to the BI. The string-length they get from the CE is 512 but the BI can only handle strings with a 60-length. Is it possible to limit the length of a string in the BPM or the CE?
    Manuel

    Hello Jun,
    I have created reporting data source in my BPM where my parameter defined is of type "STRING'.
    This data source is accessed by BW system for reporting purpose where they get an error as below -
    "STRING/XTRING types used Not supported by currently selected access method UDCGEN; cannot use this method"
    Looks like BW does not support string type, how can we make this datatype compatible?
    Please share if you have any idea.
    Thanks,
    Priya

Maybe you are looking for