How to compare 2 version strings (of the format x.x.x.x where x : {0, 99})

I am using Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production,
PL/SQL Release 11.2.0.2.0 - Production
I have a scenario like:
Table1:
Name Null Type
NAME NOT NULL VARCHAR2(64)
VERSION NOT NULL VARCHAR2(64)
Data:
Table1
Name Version
A 1
B 12.1.0.2
B 8.2.1.2
B 12.0.0
C 11.1.2
C 11.01.05
I want the output as:
Name Version
A 1
B 12.1.0.2
C 11.01.05
Basically ,I want to get rows for each name which having highest version. For this i am using following query:
SELECT t1.NAME,
t1.VERSION
FROM TABLE1 t1
LEFT OUTER JOIN TABLE1 t2
on (t1.NAME = t2.NAME and t1.VERSION < t2.VERSION)
where t2.NAME is null
Now 't1.VERSION < t2.VERSION' only works in normal version cases but in cases such as:
B 12.1.0.2
B 8.2.1.2
It fails, So i want a PL/SQL script to normalize the version strings and compare them for higher value.

Hi,
Here's one way:
ORDER BY  REGEXP_REPLACE ( REGEXP_REPLACE  ( version
                                       , '(\d+)'
                            , '0000\1'
                , '0+(\d{5})'
                , '\1'
                )This assumes that you never have more than 5 digits in a row. You can easily change that to any fixed number.
This will not cause an error if you have letters or other symbols in the string.
This makes no assumptions about how many numbers are in the string, or what characters delimit the numbers.
Here's how it works:
The inner REGEXP_REPLACE adds 4 '0's immediately before any substring of digits. This guarantees that all numbers are at least 5 digits long.
The outer REGEXP_REPLACE removes '0's from the beginning of numbers that are more than 5 digits long, which guaranteees that the numbers will be exactly 5 digits long. '00008' will come before '00012'

Similar Messages

  • How to compare two strings whether both are equal while ignoring the difference in special characters (example: & vs & and many others)?

    I attempted to compare two strings whether they are equal or not. They should return true if both are equal.
    One string is based on Taxonomy's Term (i.e. Term.Name) whereas other string is based on String object.
    The problem is that both strings which seem equal return false instead of true. Both string values have different special characters though their special characters are & and &
    Snapshot of different design & same symbols:
    Is it due to different culture or language?
    How to compare two strings whether both are equal while ignoring the difference in special characters (& vs &)?

    Hi Jerioon,
    If you have a list of possible ambiguous characters the job is going to be easy and if (& vs &) are the only charracters in concern awesome.
    You can use the below solution.
    Before comparing pass the variables through a replace function to standarize the char set.
    $Var = Replace($Var,"&","&")
    This is going to make sure you don't end up with ambiguous characters failing the comparison and all the char are "&" in this case.
    Similar technique is used to ignore Character Cases 'a' vs. 'A'
    Regards,
    Satyajit
    Please “Vote As Helpful”
    if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

  • Need to convert  Date from calendar to String in the format dd-mom-yyyy

    Need to convert Date from calendar to String in the format dd-mom-yyyy+..
    This is absolutely necessary... any help plz..
    Rgds
    Arwinder

    Look up the SimpleDateFormat class: http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
    Arwinder wrote:
    This is absolutely necessary... any help plz..For you maybe, not others. Please refrain from trying to urge others to answer your queries. They'll do it at their own pace ( if at all ).
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • How to search a string from the database?

    how to search a string from the database? starting with some character

    If you're trying to do this in a SELECT, you can use the LIKE verb in your WHERE clause.
    Here's an Example
      SELECT obj_name FROM tadir
        INTO prog
        WHERE pgmid = 'R3TR'
          AND object = 'PROG'
          AND obj_name LIKE 'Z%'.
    In this case it will select every row that obj_name starts with Z. 
    If you wanted to find every row that the field obj_name contains say... 'WIN'  you use LIKE '%WIN%'.
    Edited by: Paul Chapman on Apr 22, 2008 12:32 PM

  • How to compare versions of DMEE Format Tree in DEV, QAS and PRD

    Hi,
    Is there a way to compare version of the DMEE Format Tree in DEV, QAS and PRD?  I would just like to ensure that version in DEV is in sync with the ones in QAS and PRD before I do my changes.  It seems that Version Management of Transaction DMEE can;t compare the versions in the three systems.  Thank you very much for your inputs.
    Best regards.
    Brando

    Brando.
    DMEE is a standard transaction which will be in sync with all the servers in your landscape unless there is any customisation done and the request is not yet moved.What problem are you facing when you are trying to do REMOTE COMPARISION ?
    K.Kiran.

  • How to add a string at the End of TLFTextField without loosing current text format!

    I have a TLFTextField that loads text from external text file.
    Then a function changes the format of some parts.
    Then as soon as I add a string at the end of my TLFTextField, All previous formatting is lost!
    I use this code to add string:
    myTLF.text += "." ;
    or
    myTLFText.text = myTLFText.text.concat(".");
    Should I use another method??

    pass the text through your formatting function again, or try appendText:
    myTLF.appendText(".") ;

  • How to devide a string in the particular format

    hi friends
    my problem is that i have a string line having 150 character. i have to devide that string line by 70+70+10 character in such a way that the last word in the each line should be at single location. e.g
    this is a dummy line of string and the characters in this line are important
    suppose this is first line the 70 characerrs completes at impporant "imp" so is should keep this word together is the word length grater than 5 or 6 character then whole character should come in next line begining.
    so friends please suggest me the logic to implement that. string of line may contain any of words with or without space.
    the string is dynamic.
    thanks in advance.

    i have a string having 150 character i want to devide that string in three line first lien may contain 70 character second line also caontain 70 char and third line may contain 10 characters. but at the last word of the line should not be devided. if the last word length is 5 of 6 than the first line may have 75 or 76 character id the last word length is higher than 5 or 6 than the last word should be at initial word of second line and the forst line may have some less characters and so on for second and third line.
    for example
    suppose this is the some exaple of line is contains 77 characters
    "this is a dummy line of strings and the characters in this line are important"
    the 70 character complete in ""this is a dummy line of strings and the characters in this line are im"
    but the last word is devided in two parts it should not be there. if length of the last char is 5 or 6 beyond 70 char then the word should be in the first line
    so frirst line should be
    "this is a dummy line of strings and the characters in this line are" and "important" word should come at second line.

  • Compare two strings and the save the greater

    To devolop a vi,it can compare two strings.A string is gived,the other is saved previously.If greater,then save,or do nothing.

    Hi,
    I am assuming by "greater" you mean the string length.
    Use the string length function from the strings palette, with shift-registers on a while loop. Write to the shift-register the "greater" string.
    I am attaching a diagram screenshot for this. NOTE: depending on how you want this VI to run, you can move the input and output string control and indicator inside our outside the while loop.
    Hope this is what you were looking for.
    Khalid
    Attachments:
    strlen.gif ‏17 KB

  • How to generate current time in the format yyyy-mm-ddThh:mm:ssZ in the xslt

    Hello,
    i am tring to generate current time in the format yyyy-mm-ddThh:mm:ssZ in my xlst file.
    the following info are necessary,
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java"
    version="1.0">
    <xsl:attribute name="generationDate"><xsl:value-of select="java:format(java:java.text.SimpleDateFormat.new('yyyy-mm-dd hh:mm:ss'), java:java.util.Date.new())"/></xsl:attribute>
    but java SimpleDateFormat doesnt support yyyy-mm-ddThh:mm:ssZ.
    thanks in advance.

    Hi wwuest,
    I use the following code to generate such a date format :
              try {
                   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                   Date date = sdf.parse(strDate);
                   sdf.applyPattern("yyyy-MM-dd'T'hh:mm:ss");
                   strDate = sdf.format(date);
              } // catching the parse exceptionMaybe you could try this method and see if it pass through xsl with :
    new SimpleDateFormat("yyyy-MM-dd").applyPattern("yyyy-MM-dd'T'hh:mm:ss'Z'")Bye

  • How can I convert string to the record store with multiple records in it?

    Hi Everyone,
    How can I convert the string to the record store, with multiple records? I mean I have a string like as below:
    "SecA: [Y,Y,Y,N][good,good,bad,bad] SecB: [Y,Y,N][good,good,cant say] SecC: [Y,N][true,false]"
    now I want to create a record store with three records in it for each i.e. SecA, SecB, SecC. So that I can retrieve them easily using enumerateRecord.
    Please guide me and give me some links or suggestions to achieve the above thing.
    Best Regards

    Hi,
    I'd not use multiple records for this case. Managing more records needs more and redundant effort.
    Just use single record. Create ByteArrayOutputStream->DataOutputStream and put multiple strings via writeUTF() (plus any other data like number of records at the beginning...), then save the byte array to the record...
    It's easier, it's faster (runtime), it's better manageable...
    Rada

  • How to Compare two strings in PL/SQL

    Hi All,
    I need to compare two strings whether they are equal or not in PL/SQL.Is there any function to comparing the strings.

    Yes, the = sign.
    Are you after something like:
    IF v_string1 = v_string2 THEN
    ELSE
    END IF;?
    Edited by: Boneist on 27-Aug-2009 11:41

  • How to convert internal date to the format of user default setting

    In the BDC program, I need to convert the date, such as the sy-datum 20070427, to the format of user default that is defined in T-code SU01, such as YYYY-MM-DD or YYYY.MM.DD, and so on.
    The user format has 6 six kinds, and it is not good idea to write the code to process. So I look for the functions or CLASS method to process. I can use the function 'ITS_GET_USER_DEFAULTS' to get the user default setting of the Date format and Decimal notation.The problem is that I can not find the function or CLASS method to convert the internal date to user's date format.
    The function: CONVERT_DATE_TO_INTERNAL can not do it.
    The CLASS method: cl_abap_datfm=>conv_date_int_to_ext may be do it. But I do know how exchange the parameters, and fail to make it work finely.
    Is there the functions or CLASS method to process it?
    Thanks a lot!

    Hi John,
    create a veriable :
    data: v_date type char10.
    then after getting the date in YYYYMMDD format, write the following statement.
    WRITE SY-DATUM TO V_DATE.
    this might solve your problem.
    Regards,
    Hemant.

  • How to convert a String to Date format?

    the user enter a date in string format and the date is save in the database.
    The problem i am facing is i want to change from String to Date format.
    Here is my codes:
            public boolean insertData() throws Exception {
            boolean validFlag = false;
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            Date d = df.parse("05/18/05");
            String MY_DATE_FORMAT = "yyyy-MM-dd";
            String jobAdvertisementDate = new SimpleDateFormat(MY_DATE_FORMAT).format(d);
            String sql = "INSERT INTO companyjob (CompanyID,JobID, JobAdvertisementDate ) " +
                    " VALUES ('" + companyID + "','" + jobID + "', '" + jobAdvertisementDate + "')";
            System.out.println(sql);
            validFlag = executeSQL(sql);
            return validFlag;
        }The date is save under jobAdvertisementDate.
    My netbeans shows an error. There's a red line under DateFormat and parse inside my codes.
    PLease help me. Reply asap!!

    BebeGirl wrote:
    My netbeans shows an error. There's a red line under DateFormat and parse inside my codes.
    Red Line? Sounds ominous. I wonder what it means.
    So...what does the error say?

  • How to insert a String at the CaretPosition without moving the Caret?

    I have a JTextPane wrapped by a JScrollPane. The JTextPane is where chatroom messages appear. When a message is appended at the end, it determines whether to scroll to the bottom based on some conditions (scroll to the bottom only if the user was already viewing somewhere near the bottom). That part is working fine.
    Although the JTextPane is not editable, it allows the user to make selections using a mouse so that blocks of text can be copied from the chatroom. The default caret of JTextPane handles that for me.
    But the problem comes when the caret position is at the end of the document when my program inserts a new message with the following code:
    StyledDocument doc = textPane.getStyledDocument();
    doc.insertString(doc.getLength(), message + "\n", null);The caret was at doc.getLength() to begin with, when the new message is inserted at the end, it "pushes" the caret to a new position. The caret movement is causing JScrollPane to scroll to where the caret is visible (the bottom), therefore interfering with my scrolling algorithm (see above).
    So, when the caret is doc.getLength(), how do I insert a String at doc.getLength() with the caret staying at the original position?
    In other words, how do I insert a String at the caret position without the caret being moved?
    Note:
    1) I don't want to use setCaretPosition() to set the caret to its original position, because calling this method will trigger a CaretEvent, thus causing the JScrollPane to scroll (to the caret) which is not what I want (see above).
    2) I don't want to remove the CaretListener, cause then the JScrollPane won't scroll even when the user wants to make a multiple-page selection using the mouse (dragging the selection off screen).
    3) I want to keep the Caret at the original position so that the user won't lose his/her selection when new messages appear (which can be quite frequent).

    I keep forgetting how difficult it is to do such simple things in the text package. But it's not impossible! Here's a way to replace the relevant listeners, plus a sample implementation. If you know you'll never, ever delete any text from the JTextPane, you may not have to provide a replacement DocumentListener at all; this one just makes sure the caret isn't past the end of the document.
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import javax.swing.text.DefaultCaret;
    import javax.swing.text.Document;
    import javax.swing.text.JTextComponent;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    public class ChatCaret extends DefaultCaret
      private MyHandler newHandler;
      private PropertyChangeListener oldHandler;
      public void install(JTextComponent c)
        super.install(c);
        PropertyChangeListener[] pcls = c.getPropertyChangeListeners();
        for (int i = 0; i < pcls.length; i++)
          if (pcls.getClass().getName().equals(
    "javax.swing.text.DefaultCaret$Handler"))
    oldHandler = pcls[i];
    newHandler = new MyHandler(oldHandler);
    c.removePropertyChangeListener(oldHandler);
    c.addPropertyChangeListener(newHandler);
    break;
    Document doc = c.getDocument();
    if (doc != null)
    doc.removeDocumentListener((DocumentListener)oldHandler);
    doc.addDocumentListener(newHandler);
    public void deinstall(JTextComponent c)
    super.deinstall(c);
    c.removePropertyChangeListener(newHandler);
    Document doc = c.getDocument();
    if (doc != null)
    doc.removeDocumentListener(newHandler);
    class MyHandler implements PropertyChangeListener, DocumentListener
    private PropertyChangeListener oldHandler;
    MyHandler(PropertyChangeListener oldHandler)
    this.oldHandler = oldHandler;
    public void propertyChange(PropertyChangeEvent evt)
    Object oldValue = evt.getOldValue();
    Object newValue = evt.getNewValue();
    if ((oldValue instanceof Document) ||
    (newValue instanceof Document))
    setDot(0);
    if (oldValue != null)
    ((Document)oldValue).removeDocumentListener(this);
    if (newValue != null)
    ((Document)newValue).addDocumentListener(this);
    else
    oldHandler.propertyChange(evt);
    public void removeUpdate(DocumentEvent evt)
    int length = getComponent().getDocument().getLength();
    if (length < getDot())
    setDot(length);
    public void insertUpdate(DocumentEvent evt) { }
    public void changedUpdate(DocumentEvent evt) { }

  • How to downlad a string to the Presentation server

    Hi all
    How we can download a string to the presentation server <b>without</b> converting it to  the internal table.
    Am having a XML data as string. I want to bring that to the presentation server without converting it to internal table.
    I have tried that by converting to table and downloaded the same as BIN file ......since we are disturbing the string while converting to  itab am getting error while executing that XML file.
    <b>Error as shown below.
    Multiple colons are not allowed in a name. Error processing resource 'file:///D:/XXXXX.xml'. Line 705, Position 588
    </w:fldData></w:fldChar></w:r><aml:annotation aml:id="3" w:type="Word.Bookmark.Start" w:name="Text9"/&g...</b>
    Kindly help me in this regards.
    Thanks in advance
    Meikandan

    us the following code to convert the xml to itab which can then be use with gui_download with file type 'BIN'
    data: coutput type string ,
          xl_content type xstring ,
           binary_content     type solix_tab .
    call transformation (`ID`)
                  source flights   = flights[]
                  result xml output.
        clear: xl_content .
    *      xl_content = output .
        call function 'SCMS_STRING_TO_XSTRING'
          exporting
            text           = output
    *   MIMETYPE       = ' '
    *   ENCODING       =
         importing
           buffer         = xl_content
         exceptions
           failed         = 1
           others         = 2
        if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        endif.
        refresh binary_content .
        call function 'SCMS_XSTRING_TO_BINARY'
          exporting
            buffer     = xl_content
          tables
            binary_tab = binary_content.
    Regards
    Raja

Maybe you are looking for

  • To get selected cell info in table for WDA.

    i'm developping in netweaver2004s. a view has a table and a button. another view has input fields. i want to get cell info(selected field name not value) so i use that info in another view. i want to know same command 'GET CURSOR' in WDA. please let

  • HT1476 Charging is not supported by this accessory?

    I'm really frustrated because I have tried every possibly way to fix my iPod Touch fourth generation. There are two things wrong with it and I have already purchased things to fix them- a home button and a new charger. I am not sure this new charger

  • Problems with my new 27" i5 1tb imac (10.8.1)

    I bought this imac in July 2012, it has following problems so far: noisy fans (but fan speeds are not high, OD 1148rpm, HD 1143 rpm, CPU 939 rpm) comparing to my old mac mini that is quiet; occasional strange noise like from empty stomach; occasional

  • Which widows server 2008 release and edition supports Oracle 11g R1 64 Bit

    Hi Trying to install the Oracle 11g R1 64bit on Windows server 2008 . Hence requesting you all , which Windows server 2008 Release and Edition support Oracle database 11g R1 64bit . Thank You Edited by: user8709943 on Nov 12, 2010 10:34 AM

  • Open standard Attachments in a Custom OA Page

    Dear Experts, My requirement is to display and open attachments (stored in FND_LOBS table) in a custom OAF screen (similar to what standard attachment screen displays). I am able to display but not able to provide a proper url so that documents can b