text field with numeric values for sorting

I'm having a problem my sort. Usually, when the column follows a format, I can use a combination of INSTR and LPAD to sort correctly. In this new case, my columns does not follow a specific format.

Sample data:
with t as(
select 'xxx 10 MG yyy' sortcol from dual union
select 'xxx 5 MG yyy' from dual union
select 'xxx 28 MG yyy' from dual union
select 'aa 10% 12.5 ' from dual union
select 'aa 6.25% 12.5' from dual union
select '222 zzz 30/17.5' from dual union
select '222 zzz 30/5.5' from dual
)
select * from t

SORTCOL
222 zzz 30/17.5
222 zzz 30/5.5
aa 10% 12.5 
aa 6.25% 12.5
xxx 10 MG yyy
xxx 28 MG yyy
xxx 5 MG yyy
I want to sort the data in the
222 zzz 30/5.5
222 zzz 30/17.5
aa 6.25% 12.5
aa 10% 12.5 
xxx 5 MG yyy
xxx 10 MG yyy
xxx 28 MG yyy
I'm trying to replace all numerical values in the string to have 4 digits. For example:

xxx yyy MG 0010
xxx yyy MG 0028
xxx yyy 0005 MG
0222 zzz 0030/0017.0005
0222 zzz 0030/0005.0005

If Oracle will sort correctly digital in the form of text fields. I thought I found the solution with the regular expression:
select regexp_replace('x10x100x6.5x','([0-9]+)',lpad('\1', 4,0)) from dual

x0010x00100x006.005x
But the problem is that the backreference in the LPAD overrides the value before it run LPAD. He treats her like the literal string '\1' as oppose to the reference value: 10, 1, 6, and 5. Therefore, LPAD think length is always 2, length ('\1') = 2 instead of length('100') = 3.

Is there another method to develop all the numbers? Thank you for your time.

Hello

You can do with nested REGEXP_REPLACEs:

SELECT   sortcol
,      REGEXP_REPLACE ( REGEXP_REPLACE ( sortcol
                             , '([0-9]+)'
                          , '000\1'
                          )
               , '[0-9]+([0-9]{4})'
               , '\1'
               )     AS four_digits
FROM       t
ORDER BY four_digits
;

You probably don't want to display the string converted; you want to just ORDER BY it. It is included in the SELECT clause only if you could see what it was, for the tests.
Output:

SORTCOL         FOUR_DIGITS
--------------- ------------------------------
222 zzz 30/5.5  0222 zzz 0030/0005.0005
222 zzz 30/17.5 0222 zzz 0030/0017.0005
aa 6.25% 12.5   aa 0006.0025% 0012.0005
aa 10% 12.5     aa 0010% 0012.0005
xxx 5 MG yyy    xxx 0005 MG yyy
xxx 10 MG yyy   xxx 0010 MG yyy
xxx 28 MG yyy   xxx 0028 MG yyy

As you can see, the inner REGEXP_REPLACE adds 3 leading 0 to each number, if she need to 0, 1, 2, or 3. This means that each number will be at least 4 digits, but maybe more. The external REGEXP_REPLACE replaces 4 digits with the last 4 digits only.

Thanks for posting the sample data in a useful form. The description of the problem was very clear, and it was useful to see that you had already tried and your results on why it does not work. I wish we could mark questions as "Correct." This one was really were.

Published by: Frank Kulash, January 21, 2011 16:20

Tags: Database

Similar Questions

  • fill in the text field with the caption for the radio list

    Hi, I'm looking for an answer to this all morning.  I need to use the value of a list of radio to populate a text field.  I can get the selected numeric value OK with

    $.rawValue = form1. #subform [0]. . Table3.Row1 #SubForm [0]. . RawValue location [0]

    but I want to get the text associated with the value element.  This could be the legend of the selected option button, since it is the same thing.  I don't want to use an if statement because I have a lot of forms to create and that would change things a few times in each shape.  How can I get the value of the text of the column of the item below?

    screenshot.17.png

    Try the following with two modifications to your hierarchy.

    (1) currently, you do not have a name for Page1. Make sure that you assign a name for ease of use. ("Page1").

    (2) define a name for the subform that contains PeriodRadio. ("Subform1").

    $.rawValue = form1. Page1. Table3.row2. Subform1. PeriodRadio.selectedMember (). caption.value.text.value;

    Thank you

    Srini

  • When a box is checked, fill a text field with a value

    I don't know that it's simple; However, I am very new to acrobat and javascript.

    Here's what I want to do:

    I have a checkbox field and a text field. If the checkbox is turned "on" I want to fill the text field with a specific numeric value.  If she isn't 'unchecked' there is not value or value 0.  Any help is appreciated.

    Enter this code in the custom of your text field calculation script:

    This.getField("CheckBox1").value = Event.Value == "Off"? 0: 1234;

  • Cannot get 'IN' text field with multiple values.

    I have a text field (P11_SERIAL_NUMBERS) someone would use to enter multiple values (i.e. of the serial numbers). I tested various methods but can't seem to get anything working. I used values such as ' 12929', '19191' or ('11919', ' 19192 ', ' 1111') or 12121,121333.»

    I have to analyze this area after the entrance is and update P11_SERIAL_NUMBER to something like ("121212 ', 121211', '292929'). The report is a SQL query returning the body of a PL/SQL function. I build the query in an anonymous block to something like the following:

    SELECT apex_item.checkbox (1, instance_number) Ins,.
    apex_item. Text(2,i.instance_number) instance_number.
    apex_item. Text(3,i.item_number) item_number.
    description of the apex_item. Text(4,i.Description),
    Serial_number apex_item. Text(5,i.serial_number),
    i.party_name,
    i.status_name
    Cycsi_item_details_v I have
    WHERE i.item_number IN (SELECT v.item_number FROM cycsi_installed_base_v WHERE v.serial_number = i.serial_number v)
    AND i.item_number AS NVL ('%' |') XLA' | ' %','%')
    AND NOT EXISTS (SELECT d.item_serial_number FROM cy_fco_d, d WHERE d.fco_id = 2803 AND d.item_serial_number = i.serial_number) AND i.serial_number IN ('61763 ', ' 61621');

    However, when I enter several values that nothing ever went back to the SUMMIT even though the SQL query returns more rows. I run the application in debug mode and it seems to show the values correctly.

    0.11: show report
    0.12: determine the column headings
    0.12: analyze the query such as: TRAFFIC
    0.15: binding: ": P11_MODEL_NUMBER"= "P11_MODEL_NUMBER" value = "XLA"»
    0.16: binding: ": P5_FCO_ID"= "P5_FCO_ID" value = "2803"»
    0.17: binding: ": P11_SERIAL_NUMBERS"= "P11_SERIAL_NUMBERS" value = '(' 61621', ' 61763')""
    0.19: print the column headings
    0.19: loop lines: 15 rows
    No data found

    If I add only a serial number at a time as the APEX application returns the line correctly.


    Does anyone have an idea what I'm doing wrong or what best way to solve this problem?
    Thank you
    John

    Published by: Jennifer on July 13, 2010 15:23

    Hi John,.

    I just tried a report region based on PL/SQL query encoded using your method to refer to element names in the query string of back:

    declare
       q varchar2(100) := 'select ename, job from emp';
    begin
       if :P2_ENAMES is not null then
            q := q || ' where ename in :P2_ENAMES';
       end if;
    
       wwv_flow.debug('*** Query: ' || q);
    
       return q;
    end;
    

    As I suspected, he did not work for me P2_ENAMES was ('KING') or ('KING', 'SMITH'). I think it's because of the reason for which I gave in my previous post - ApEx passes off the coast of the dynamic execution of SQL string, it does not automatically replace the mention: P2_ENAMES with the value of the element. I don't know how it can work for you.

    If I change the code I proposed:

    declare
       q varchar2(100) := 'select ename, job from emp';
    begin
       if :P2_ENAMES is not null then
            q := q || ' where ename in ' || :P2_ENAMES;
       end if;
    
       wwv_flow.debug('*** Query: ' || q);
    
       return q;
    end;
    

    It works very well if one or several names are specified.

    I took a blow to modify your code for the construction of the query string - does not immediately guarantee, it'll work because I can't test (might be missing a parenthesis or quotation) it but you should get the idea:

    -- start with initial valid query that ApEx can parse to determine column names
    q := 'SELECT apex_item.checkbox(1, instance_number) ins, apex_item.text(2, i.instance_number) instance_number,
                 apex_item.text(3, i.item_number) item_number, apex_item.text(4, i.description) description,
                 apex_item.text(5, i.serial_number) serial_number, i.party_name, i.status_name
            FROM cycsi_item_details_v i
           WHERE i.item_number IN (SELECT v.item_number
                                     FROM cycsi_installed_base_v v
                                    WHERE v.serial_number = i.serial_number)';
    
    -- add model number condition if specified
    if :P11_MODEL_NUMBER is not null then
       q := q || ' AND i.item_number LIKE ''%' || :P11_MODEL_NUMBER || '''%''';
    end if;
    
    -- add serial numbers condition if specified
    if :P11_SERIAL_NUMBERS is not null then
       q := q || ' AND i.serial_number IN (' || :P11_SERIAL_NUMBERS || ')';
    end if;
    
    -- add FCO id condition if specified
    if :P5_FCO_ID is not null then
       q := q || ' AND NOT EXISTS (SELECT d.item_serial_number
                                     FROM cy_fco_d d
                                    WHERE d.fco_id = ' || :P5_FCO_ID || '
                                      AND d.item_serial_number = i.serial_number)';
    

    I know that has focused on getting this code works, but I would be remiss in my duties if I didn't at least mention the risk of SQL injection. You may already know this, but unless you do a good job to validate the values of the element used in the query, you could open yourself up to a SQL injection attack. For example, imagine what that would be returned if a hacker sharp entered "12345) GOLD (1 = 1" in the field of P11_SERIAL_NUMBERS - you would get all that may or may not be a security problem.

    Hope this helps,
    John

  • Text field with AutoComplete do not store Item Value for Cascading LOV

    Hello

    I have created a form to the APEX 4.2, and two elements on the page have a problem. The first point is a text field with AutoComplete for the PROVIDER. The second element is a list select number that has the PROVIDER as part of waterfall to fill.

    When a user selects one of the values that the field can be seized semiautomatic provider , the value autocomplété should make the selection list produce the numbers respective associated PROVIDER. The problem that I am running is that AutoComplete is not give PROVIDER selection list value is filled.

    For example: if I type 'st' in the PROVIDER field that autocompletes to "steve" is selected, the NUMBER field must interrogate him for the numbers where VENDOR = steve. However, after reviewing the Session State from the PROVIDER element, the contained value is always only "st."



    Here are the settings I have for the field PROVIDER : and NUMBER:

    name.JPGnumber.JPG

    There should be a way to have the value of the seized field semi-automatic to account for what appears after selecting a value, but I don't know what it is. You can provide any help would be appreciated.

    Thank you!

    your query full auto would: select supplier_name | ' ('| supplier_id |') '

    provider AutoComplete onChange, get the supplier_id and then value the selected drop-down list by using this code.

  • Ghost of text for a text field with Add Action

    I have a text field with text ghost. Also, there is a button to add additional text fields. When a user clicks on the 'add an additional text field button' new text field appears but without the ghost of the original text field text. I tried the script of the click event of the button to fire or run:

    textfield.execEvent("ready:form"); or textfield.execEvent("form:ready");

    Why 2 ways? LiveCycle has two ways to present it:

    (1) on the drop-down list for events (e.g. form: ready)

    (2) on the name of the field at the top of the script after box selected event on the menu drop-down (for example textfield.ready:form: :-(Javascript, client)

    Is there a better way to do it? My concern is that if I managed to shoot the event form: ready or ready: shape the event can reset all the text from the original text of default ghost of "Kansas City Royals. Thank you

    https://workspaces.Acrobat.com/?d=w3PioRrv8DUp2ruhoOY * 8g

    Put your event form script: ready in the initialize event.

    Kyle

  • Is it Apex_Item function for "text field with AutoComplete?

    Hi all
    Is it Apex_Item function for "text field with AutoComplete? I can't find it in the website http://apex.oracle.com/i/doc/AEAPI/apex_item.htm

    Respect,
    Taylor.

    Hello

    I think that there is not. If there is, it is not documented.

    You can use the normal text field and Add AutoComplete using jQuery UI and jQuery autocomplete plugin.
    Those who are willing to Apex 4

    See for example this post how manually to add autocomplete text field
    Plugin of JQuery autocomplete

    Kind regards
    Jari

  • Problems with the filling of a text field with 2 other fields data


    I have 3 domains Tools_1a_pri, Tools_1a_pri_other, Tools_1a_pri_txt.

    Tools_1a_pri is a drop-down list box with a predefined list. One of the options is the 'other '.  If 'Other' is selected, the text Tools_1a_pri_other field becomes visible for users to enter the name of the other tool.

    The Tools_1a_pri_txt is a text field with a calculation that shows a text indicating that no tool has been selected or the Tools_1a_pri & or Tools_1a_pri_other.

    When I select one of the predefined tools, everything works.  When I choose the other, it seems that nothing has changed.  Must I click another field before.  It's confusing for the user.

    Tools_1a_pri validate code
    this.getField("Tools_1a_pri_Other").display = event.value is "Other"? Display.visible: display.hidden;

    Computer Tools_1a_pri_txt code
    If nothing is selected, follow these steps
    If (getField("Tools_1a_pri").value.length < 2) {}
    event.target.textColor = color.red
    Event.Value = "no identified main tool";
    } else if (getField("Tools_1a_pri").value! = 'Other') {}
    If not do that if the other is selected
    event.target.textColor = color.black
    Event.Value = getField("Tools_1a_pri").value;
    } else if (getField("Tools_1a_pri").value = 'Other') {}
    If not do so if the other is not selected
    event.target.textColor = color.black
    GetField("Tools_1a_pri").value = Event.Value + "-" + getField("Tools_1a_pri_Other").value;
    }

    You have made the classic mistake of using the assignment operator in a statement instead of the comparison operator. Change this line:
    } else if (getField("Tools_1a_pri").value = 'Other') {}

    To do this:

    } Else if (getField("Tools_1a_pri").value == 'Other') {}

  • Text field with AutoComplete is always NULL

    Greetings,

    I am new to Apex, so I don't know I'm missing something obvious. I use Apex 4.0.1 what I've done is created a form on a page of table and added a new text with page of AutoComplete element. This new field of text does not match a column in the table. What I'm trying to do, is allow the user to use the AutoComplete feature to make a choice. Then when the user submits the page, I want to use the substr function on the value of the field of AutoComplete and fill one of the fields in table. I tried using the PL/SQL functions in validations and calculations, but I found that the autocomplete field value is always NULL. I can access the other fields that are associated with a fine table column. It must be something simple. Thanks for your help.
    Page Items
    P2_F1  - text field with auto complete. Not associated with a table column
    P2_F2 – Text field. Is associate with a table column
    This is what I want to do:
    
    Entered this in a validation
    begin
    if :P2_F1 is not null then
       :P2_F2 := substr(:P2_F1,1,5);
    end if;
    end;
    Thanks again

    Published by: LRM on 22 January 2011 17:25

    Hello

    In calculations, you must use:

    Item name: P2_F2
    Type: SQL Expression
    Point calculation: after submit
    calculation: substr(:P2_F1,1,5)
    Condition type: the value of element in the expression is not null
    Expression 1: P2_F1

    Kind regards

    Patel Kartik
    ---------------------------------------------------------------
    http://patelkartik.blogspot.com/
    http://Apex.Oracle.com/pls/Apex/f?p=9904351712:1

  • Apex 4.02 BUG: text field with AutoComplete. wrong help text

    The rest of the wizard for a text field with AutoComplete you reach a screen where you can enter an LOV query. The text of the query box has following help text

    Enter the query that returns the list of values. The query must select two columns in the following order, first a display value then a return value. For example:

    Select ename, empno
    WCP


    When you select two identical columns, remember to use the single column alias, for example:

    Select d, r ename ename
    WCP

    However, the query must return only 1 value.

    Thank you, Rene, I fixed in 4.1.

    Concerning
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • My EO fields are numeric values, but when I create the EOIMPL class they are converted to INTEGERS numbers. Why, please explain.

    Mr President

    My EO fields are numeric values, but when I create the EOIMPL class they are converted to INTEGERS numbers. Why, please explain.

        public static final int PURQTY = AttributesEnum.Purqty.index();
        public static final int STAXRATE = AttributesEnum.Staxrate.index();
        public static final int UNITPURPRICE = AttributesEnum.Unitpurprice.index();
        public static final int SALQTY = AttributesEnum.Salqty.index();
        public static final int UNITSALPRICE = AttributesEnum.Unitsalprice.index();
        public static final int PARTICULARS = AttributesEnum.Particulars.index();
        public static final int AMOUNT = AttributesEnum.Amount.index();
    

    Can keep us in digital format.

    Concerning

    No.... These int values not the type of display object attributes. These integers is the index of attributes.

    To determine the type of the VO attributtes, you should see the Get accessor of the attribute and the setter

    as

      /**
       * Gets the attribute value for the calculated attribute CountDockets.
       * @return the CountDockets
       */
      public BigDecimal getCountDockets()
      {
        return (BigDecimal) getAttributeInternal(COUNTDOCKETS);
      }
    
      /**
       * Sets value as the attribute value for the calculated attribute CountDockets.
       * @param value value to set the  CountDockets
       */
      public void setCountDockets(BigDecimal value)
      {
        setAttributeInternal(COUNTDOCKETS, value);
      }
    

    This means that the attribute type CountDockets BigDecimal

  • How to add an animation to a text field with two lines?

    I have a text field with two or more lines. Why is it not possible now to apply a text animation?àpe_textfield.jpg

    Animating text, by design, only works on a single line of text.

    To use it for multiple lines, you can either create two separate titles or keyframing to create your own animation effect.

  • Creating a page of my Web site that allows users to fill out text fields, with basic formulation tools (text sizes, formatting, etc.).

    Hey, I would like to create a page on my Web site that allows users to fill out text fields, with basic formulation tools (text sizes, formatting, etc.).

    Another thing I need to allow users must be able to upload their own graphics to the pre-assigned fields. Thank you please advise me on how I would go to this topic.

    Nothing to do with the Muse. You need a system dynamic as Joomla, Wordpress, Drupal and so on. Otherwise, there is no way to store your information.

    Mylenium

  • Turn off the text box with the value of the checkbox

    Hello people,

    I am trying to activate or disable the text box with the value of the CHECKBOX, I have got the same thing with the BOX of ELECTION, with the javascript as follows: -.

    HEADER HTML
    ----------------------
    < script type = "text/javascript" >
    function disableOnValue (o)
    {
    If (o.value == 'Y')
    {
    document.getElementById('P2_TEXT_BOX1').disabled = false;
    document.getElementById('P2_TEXT_BOX2').disabled = false;
    document.getElementById('P2_TEXT_BOX3').disabled = false;
    }
    on the other
    {
    document.getElementById('P2_TEXT_BOX1').disabled = true;
    document.getElementById('P2_TEXT_BOX2').disabled = true;
    document.getElementById('P2_TEXT_BOX3').disabled = true;
    }
    }
    < /script >
    ---------------------

    under region Source whose Point display is < b > before < /b > foot and sequence is the last sequence of the entire region
    ----------------
    < script type = "text/javascript" >
    If (document.getElementById('P2_RADIO_BUTTON_0').checked is true)
    {disableOnValue (document.getElementById('P2_RADIO_BUTTON_0')) ;}
    on the other
    {disableOnValue (document.getElementById('P2_RADIO_BUTTON_1')) ;}
    < /script >
    ----------------

    and finally, to the title of point RADIO_BUTTON, HTML Form element attributes: -.
    -----------
    OnChange = "JavaScript:disableOnValue (this); »
    ----------

    the thing above works very well with the help of the RADIOBUTTON, but I want to try same thing with the CHECK_BOX I also tried a few changes but did not have any success so if someone help out me even that will be great and appreciated!


    Thank you

    Kind regards
    Kumar

    I also have the following in the Footer region region:

    <script type="text/javascript">
    x($x('P12_CHECKBOX'));
    </script>
    

    This is just to make sure that the items are disabled when the page is loaded, because the checkbox is deactivated

    Andy

  • Auto fill the text field with user logon Windows users

    Can someone tell me how to achieve the following objectives, I want a text field in my form to be filled automatically with the windows users username.

    I found an answer 'Define a new variable REMOTE_USER - user domain\username Request.Server should display'

    This script/s should I use on the forum and put it where?

    Thanks in advance.

    Steven Thompson

    Sydney, Australia

    First you must put the code I provided in a special level of the Acrobat application folder and then restart Acrobat or Reader.

    Enter the folder level Scripts by Thom Parker

    Then, in your form field, you can use the following code in the "custom javascript calculation:

    Event.Value = Identity.loginName;

    Note the capitalization of the word 'identity '.

    The application-level script will work with Acrobat and LiveCycle Designer Forms.

    If you want to use a feature, you can use the following code in an application-level folder:

    getIdentity = app.trustedFunction (function (cProperty) {}
    app.beginPriv ();
    cValue = identity [cProperty];
    if(cValue == undefined) {/ / check for the unknown identity property}
    App.Alert ("property of the identity is not known:" + cProperty);
    cValue ="";
    } / / end if not defined
    return cValue;
    app.endPriv ();
    } / / end app.trustedFuncton
    ) / / end getItentity

    And then in the "custom calculation script:

    Event.Value = getIdentity ("loginName"); get the loginName

Maybe you are looking for

  • Satellite L640 hangs at the splash screen

    Hi all I have a L640 / 01 H that I bought earlier this year. In addition to the original Windows 7 OS, I installed a Linux system on a separate partition. Earlier today, I was using Linux (which is what I normally use) and everything was really slow.

  • 2000-314nr HP: can I set my computer laptop processor?

    My computer laptop processor can be improved? I tried to find info but could not. product #: A7A84UA #ABA 1.65 GHz AMD E-450

  • Challenge of data logging

    I designed the VI attached to achieve a certain task. I've been on it since yesterday but decided to take a different approach. I want to save data in the log.xls file every five seconds (or as the timer would clarify), continuously. When the counter

  • Database Toolbox and Chinese characters

    Hi all I have a problem with a function where users can search inside a Microsoft SQL Server database for a specific entry. I used the database with the DB tools tool run Query.vi, users can add keyword here for example. 'blue %' inside a control of

  • Reformatted a hard drive now in a closed Chamber. Not an assigned drive letter. Installation in a NTFS folder empty?

    Hello. I have a few external hard drives. I want them to be little permanent on my laptop or desktop for creating media. The only way seems to be to not assign a drive letter and let windows assign/change it a whenever I connect it or assign a drive