RegExp_. Using substr

Hi - I need to extract the string after the last ' / ' and everything before the last ' / '. Possible to do using substr and instr but I would like to know how this can be done using regexp_substr.

for example: / Merchants/Retail/ShopBrand/Home/Holidays/Bed

My requirement is to extract 'Reads', which is after the last ' / ' and '' / Merchants/Retail/ShopBrand/Home/Holidays which is before the last ' / '.

Help, please

Could you give the explanation as well to '. * /', '' ?

We receive all the strings until the last ' / ' and substituting null

And my second (not a Cleaver) option would be:

SELECT REGEXP_REPLACE(REGEXP_SUBSTR('/Merchants/Retail/ShopBrand/Home/Holidays/Bed', '.*/'), '.$', '') FIRST_REQUIREMENT FROM DUAL;

Here, we remove the last character. Take a look at the documentation to go further: http://docs.oracle.com/database/121/ADFNS/adfns_regexp.htm#ADFNS1003

Kind regards.

Tags: Database

Similar Questions

  • How to use substr to search and show as an ouput in oracle 11g

    Hi all

    Suppose I have oracle.india.com1.1234 in my value line so I need not to show the India as output. I need to display in the .csv (Excel)

    Thank you

    You can use SUBSTR + INSTR:

    with t as)

    Select 'oracle.india.com1.1234' union str double all the

    Select "oracle.England.com1.1234" from double

    )

    Select str,

    substr (STR, InStr(STR,'.') + 1, instr(str,'.',1,2) - instr(str,'.') - 1) new_str

    t

    /

    STR NEW_STR
    ------------------------ ------------------------
    Oracle.India.COM1.1234 India
    oracle.England.com1.1234 England

    SQL >

    Or use regular expressions:

    with t as)

    Select 'oracle.india.com1.1234' union str double all the

    Select "oracle.England.com1.1234" from double

    )

    Select str,

    regexp_substr (str,'[^.] +', 1, 2) new_str

    t

    /

    STR NEW_STR
    ------------------------ ---------------------
    Oracle.India.COM1.1234 India
    oracle.England.com1.1234 England

    SQL >

    SY.

  • WE SHOULD NOT USE SUBSTR FUNCTION...

    Hello

    ex: [email protected] , [email protected] [email protected]

    AS THIS HUNDRED PLATE IS HERE.

    QUERY:

    I DON'T WANT THAT YAHOO, GMAIL LIKE THAT... WE SHOULD NOT USE SUBSTR FUNCTION...

    THIS IS AN INTERVIEW QUESTION

    Thank you

    Try:

    Select regexp_replace (' [email protected]',' ^. * @(.*)-.) (. *)', '\1') twice;

  • How to use substr and instr, where the line of input Multi text

    Hi all

    with

    data in the form of)

    Select ' Mary America.1234 Southridge Park Dr... Samna Lorie.MO.31234..' double val

    Union of all the

    Select 'Bill Johnson.Apartment 3 b. Sterling.VA.20166.3 Plaza Falke' of the double

    )

    Select

    regexp_substr (shipping_instructions, "[^ #] +' 1, 1") name

    , regexp_substr (shipping_instructions, "[^ #] +' 1, 2") address

    , regexp_substr (shipping_instructions, "[^ #] +' 1, 3") city

    , regexp_substr (shipping_instructions, "[^ #] +' 1, 4") State

    , regexp_substr (shipping_instructions, "[^ #] +' 1, 5") zip

    , regexp_substr (shipping_instructions, "[^ #] +' 1, 6") County

    FROM (select REGEXP_REPLACE (val, ' \.)) () [^.])', ' #\1 ") data shipping_instructions)

    (1)'Mary America.1234 Southridge Park Dr... Samna Lorie.MO.31234..'

    (2)'Bill Johnson.Apartment 3 b. Sterling.VA.20166.3 Falke Plaza. »

    "Mary America. 1234 Southridge Park Dr. Samna Lorie. MO.31234..'

    NAME ADDRESS CITY ZIP County SATE

    ---------                  --------                                ------------           ------           -------    -- -----

    Married America 1234 Southridge Park Dr.    Samna Lorie MO 31234  NULL VALUE

    "Bill Johnson. Apartment 3B. Sterling. VA. 20166. Falke Plaza 3... "

    NAME ADDRESS CITY ZIP County SATE

    ----------------      -----------------        -------       -----        ---         --------

    Bill Johnson apartment 3B Sterling, WILL 20166 3 Falke Plaza.

    Problem

    ---------

    (1) if the value, if the County (if null) value then it shows the ZIP with dot's (.) value, in the 31234 above..,.

    How to solve this problem?

    (2) another possible to fix the code, I want to use substr and InStr.

    (3) who is the best approach?

    Conditions:

    --------------

    (1) shipping_instructions column has the value with "Mary America.1234 Southridge Park Dr... Samna Lorie.MO.31234... »

    This means it combined all the similar name, address, city, State, zip

    (2) we insreted in the table separately.

    =========================

    / * Use Substr and Instr * /.

    =========================

    I used substr and instr, but I'm getting the money results (no point in the address).

    "America Mary. 1234 Southridge Park Dr. Samna Lorie.MO.31234..'


    NAME ADDRESS CITY ZIP County SATE

    ---------                  --------                                ------------           ------           -------    -- -----

    Mary America 1234 Southridge Park Dr. Samna Lorie MO 31234  NULL VALUE

    But I need the results (no point in the address)

    NAME ADDRESS CITY ZIP County SATE

    ---------                  --------                                ------------           ------           -------    -- -----

    Mary America 1234 Southridge Park Dr.    Samna Lorie MO 31234  NULL VALUE

    Hello

    994122 wrote:

    Hello

    (1) how do to do this, use the substr and instr functions?

    Thank you

    You can't do all the work with SUBSTR and INSTR; you need regular expressions to obtain a string delimited by a #.

    Once you have such a string, then you can use SUBSTR and INSTR (instead of REGEXP_SUBSTR) to get the separate secondary strings:

    WITH got_delimited_string AS

    (

    SELECT REGEXP_REPLACE (val

    , '\. ([^ .]| $)'

    , '#\1'

    ) AS delimited_string

    FROM the data

    )

    got_pos AS

    (

    SELECT delimited_string

    , INSTR (delimited_string, "#", 1, 1) AS pos_1

    , INSTR (delimited_string, "#", 1, 2), pos_2

    , INSTR (delimited_string, "#", 1, 3) AS pos_3

    , INSTR (delimited_string, "#", 1, 4) AS pos_4

    , INSTR (delimited_string, "#", 1, 5) AS pos_5

    , INSTR (delimited_string, "#", 1, 6) AS pos_6

    OF got_delimited_string

    )

    SELECT SUBSTR (delimited_string, 1, pos_1 - 1) AS the name

    SUBSTR (delimited_string, pos_1 + 1, pos_2 - (pos_1 + 1)) AS address

    SUBSTR (delimited_string, pos_2 + 1, pos_3 - (pos_2 + 1)) AS city

    SUBSTR (delimited_string, pos_3 + 1, pos_4 - (pos_3 + 1)) AS State

    REPLACE (SUBSTR (delimited_string, pos_4 + 1, pos_5 - (pos_4 + 1))

    , '.'

    )                                                           AS zip

    SUBSTR (delimited_string, pos_5 + 1, pos_6 - (pos_5 + 1)) AS the County

    OF got_pos

    ORDER BY delimited_string

    ;

  • data of cutting using substring and instring, and storage in a new table

    Hi all

    I have an emp_address 2tables, address as below:
    ---------------------------------------------------------------
    create the table emp_address (emp_id varchar2 (10), address varchar2 (100));

    Insert into EMP_ADDRESS
    (EMP_ID, ADDRESS)
    Values
    ('101', 'street1 fremont CA 94538');
    Insert into EMP_ADDRESS
    (EMP_ID, ADDRESS)
    Values
    ("102", "Street.2 fremont, CA 94537');
    COMMIT;


    create the address table (emp_id varchar2 (10), street varchar2 (20), city varchar2 (15), State varchar2 (10), zip varchar2 (10));

    -----------------------------------------------------------------------------
    Emp_address data as below:

    emp_id address

    street1 101 fremont CA 94538

    102 fremont, CA 94537 Street.2

    ------------------------------------------------------------------------------
    now I read data emp_address and split the data of the address column and record these data in the address table like as below

    emp_id Street City State Zip Code
    street1 101 fremont, ca 94538
    102 fremont, ca 94537 Street.2

    -------------------------------------------------------------------


    I'm trying to divide these data using substring and instring. Actually my problem was between the data a few times I have 1tab or 2tabs and sometimes 3tab. If the number of tab spaces is not constant.

    So can u help me in this case.

    Thanks in adavnce

    position of reference BluShadow

    WITH emp_address AS (SELECT   '101' emp_id,
                                  'street1 fremont CA 94538' address
                         FROM     DUAL
                         UNION ALL
                         SELECT   '102',
                                  'street2  fremont CA 94537'
                         FROM     DUAL),
        emp_address_list_temp AS
          (SELECT       emp_id,
                        SUBSTR (
                          address,
                          DECODE (LEVEL,
                                  1, 1,
                                  INSTR (address, ' ', 1, LEVEL - 1) + 1
                                 ),
                          DECODE (
                            INSTR (address, ' ', 1, LEVEL),
                            0,
                            LENGTH (address),
                            INSTR (address, ' ', 1, LEVEL)
                            - DECODE (LEVEL,
                                      1, 0,
                                      INSTR (address, ' ', 1, LEVEL - 1)
                                     )
                            - 1
                          )
                        )
                          address,
                        LEVEL rn
           FROM         emp_address
           CONNECT BY   LEVEL <=
                          LENGTH (address) - LENGTH (REPLACE (address, ' ')) + 1
           GROUP BY     emp_id, address, LEVEL),
        emp_address_list AS
          (SELECT   emp_id,
                    address,
                    ROW_NUMBER () OVER (PARTITION BY emp_id ORDER BY rn) rn
           FROM     emp_address_list_temp
           WHERE    TRIM (address) IS NOT NULL)
    SELECT     emp_id,
               (SELECT   address
                FROM     emp_address_list e2
                WHERE    e2.emp_id = e1.emp_id
                     AND rn = 1)
                 street,
               (SELECT   address
                FROM     emp_address_list e2
                WHERE    e2.emp_id = e1.emp_id
                     AND rn = 2)
                 city,
               (SELECT   address
                FROM     emp_address_list e2
                WHERE    e2.emp_id = e1.emp_id
                     AND rn = 3)
                 state,
               (SELECT   address
                FROM     emp_address_list e2
                WHERE    e2.emp_id = e1.emp_id
                     AND rn = 4)
                 zip
    FROM       emp_address_list e1
    GROUP BY   emp_id
    
  • A string into the text and numbers using SUBSTR and INSTR

    I have the sample data. I know it's terrible database designed for a combination of text and numbers in the same field, but I can't change the business process.

    That's what I have so far:

    set linesize 5000
    
    WITH table_data
         AS (SELECT 'R: JASON BOURNE 12341560' str FROM DUAL UNION ALL
             SELECT 'R: FATS DOMINO 23432342' str FROM DUAL UNION ALL
             SELECT 'R: MARTIN LUTHER KING 3334156' str FROM DUAL UNION ALL
             SELECT 'R: TOM CRUISE 6547123' str FROM DUAL UNION ALL
             SELECT 'R: TOMMY DE GROOT 1212124' str FROM DUAL UNION ALL
             SELECT 'R: GRIM REAPER 1345245' str FROM DUAL UNION ALL
             SELECT 'R: DOCTOR DEATH THE FIRST SMITH 24356178' str FROM DUAL)
    SELECT str
         , TRIM(SUBSTR(str, INSTR(str, ' ', 1, 1), INSTR (str, ' ', 1, 2) - INSTR (str, ' ', 1, 1))) first_name
         , REPLACE(SUBSTR(str, INSTR (str, ' ', 1, 2)+1, 999), SUBSTR(str,LENGTH(str)-6,7), '') last_name
         , SUBSTR(str,LENGTH(str)-6,7) emp_num
      FROM table_data;
    
    STR                                      FIRST_NAME    LAST_NAME                 EMP_NUM
    ---------------------------------------- -----------------------------------------------
    R: JASON BOURNE 12341560                 JASON         BOURNE 1                  2341560
    R: FATS DOMINO 23432342                  FATS          DOMINO 2                  3432342
    R: MARTIN LUTHER KING 3334156            MARTIN        LUTHER KING               3334156
    R: TOM CRUISE 6547123                    TOM           CRUISE                    6547123
    R: TOMMY DE GROOT 1212124                TOMMY         DE GROOT                  1212124
    R: GRIM REAPER 1345245                   GRIM          REAPER                    1345245
    R: DOCTOR DEATH THE FIRST SMITH 24356178 DOCTOR        DEATH THE FIRST SMITH 2   4356178
    
    7 rows selected.
    

    I need to:

    1 extract the first name - which is always the first name after the 'r' - I've got that little works very well.

    2 extract the name - should be the last word before the number, if e.g. for the last night, I wish only that 'SMITH' and 'KING' for the 3rd line and "GROOT" for the 5th line.

    3. remove the number at the end, regardless of the length - some of the examples above are 8 long numbers so my attempt above does not work.

    I can't use any REGEXP or REGEXP_SUBSTR because they are not registered in the EUL I'm using discoverer, I can only use INSTR AND SUBSTR.

    I was wondering if someone might be able to help please?

    Any advice much appreciated.

    Thank you

    AW, go on them, as it's Christmas, I'm feeling generous...

    SQL > ed
    A written file afiedt.buf

    1. WITH table_data (SELECT "r: JASON BOURNE 12341560' DOUBLE UNION ALL STR ')
    2. SELECT "r: FATS DOMINO 23432342' str OF DOUBLE UNION ALL.
    3. SELECT "r: MARTIN LUTHER KING 3334156' str OF DOUBLE UNION ALL.
    4. SELECT "r: TOM CRUISE 6547123' str OF DOUBLE UNION ALL.
    5. SELECT "r: TOMMY GROOT 1212124' str OF DOUBLE UNION ALL.
    6. SELECT "r: GRIM REAPER 1345245' str OF DOUBLE UNION ALL.
    7. SELECT "r: DOCTOR DEATH FIRST SMITH 24356178' FROM DUAL str.
    8                     )
    9 select substr (str, 1, instr(str,' ')-1) as a first name
    10, substr (substr (str, 1, instr(str,' ',-1)-1), instr (substr (str, 1, instr(str,' ',-1)-1),' ', 1) + 1) as last_name
    11, substr (str, instr (str, ' ',-1) + 1) as emp_num
    12 years of (select replace (str,'R: ') as str)
    table_data 13
    14*        )
    SQL > /.

    FIRST_NAME LAST_NAME EMP_NUM
    ---------------------------------------- ---------------------------------------- ----------------------------------------
    JASON BOURNE 12341560
    FATS                                     DOMINO                                   23432342
    MARTIN                                   KING                                     3334156
    TOM                                      CRUISE                                   6547123
    TOMMY                                    GROOT                                    1212124
    GRIM                                     REAPER                                   1345245
    DOCTOR SMITH 24356178

    7 selected lines.

  • using substr in the select statement

    Hi all

    I'll have a column as below from a table values.

    "404-297-9559 UNLISTED."

    "123 211 2345 KGTFE".

    "123 293 2789 GFT.

    OUTPUT should be like below... is it possible in sql oracle and my client uses the 8i version.

    404-297-9559

    123-211-2345

    123-293-2789

    Thank you

    KBS

    2804972 wrote:

    I gave only for three values of the column as an example, there are millions of records... hard coding is not possible. Please suggest me other

    Thank you

    KBS

    Where does show that you need to hard no matter what code?

    The comment in the code indicates that the WITH clause is just used to provide sample data to the query (so I can't create a table in my database).  What keeps you using the same query against your own data table?  Do you really understand the basic concept of a SQL selection in a table?  Did you even try and understand the code?

    Is it really that hard for you to have tried to do:

    Select substr (yourcolumname, 1, instr (yourcolumnname,' ', 1)-1) as txt

    of yourtablename

  • In the Select statement using substring comparison

    Hello

    Based on the requirement of the enterprise, I m trying to get geography_element4 to the hz_geographies table that corresponds to the value of the p_city parameter.

    Here, I take p_city from the 4th character value to 8 characters.

    For under query, I m not getting the correct result. The statement is true?   GE.geography_element4 as substr(:p_city,4,8);

    SELECT UPPER (ge.geography_element4)

    OF apps.hz_geographies ge

    WHERE ge.geography_type = "zip_code".

    AND ge.geography_name = SUBSTR(:postal_code,1,5)

    AND ge.created_by_module = 'EBTAX_CONTENT_UPLOAD. '

    AND ge.country_code = 'en '.

    AND ge.geography_element4 like substr(:p_city,4,8);

    Thank you.

    ef2019c7-080c-4475-9cf4-2cf1b1057a41 wrote:

    Can I use something like '% substr(:p_city,4,5) % '.

    Yes, you should, but using the correct syntax. Do you understand how AS works? It involves wildcards are used in similar Configuration. Otherwise, it's same as equals. Assume that p_city is "FT LAUDERDALE". Then substr(:p_city,4,5) is 'LAUDE '. Then ge.geography_element4 AND as substr(:p_city,4,5) will compare "FT. LAUDERDALE" "LAUDE", of course, without a game. When wrap you it with jokers '% "| substr(:p_city,4,5) | '%' AS get ge.geography_element4 that contains "LAUDE" and "FT LAUDERDALE" will be a game.

    SY.

  • Using substr / instr to analyze a filepath help

    I can't parse a string by saying using sql. I have a full path column. The files are similar to:

    C:\Users\Guest\Pictures\example.jp

    I want to be ablt to simply enter the name of the image file. I worked on several variants of a query by using the function substr and instr function. I came up with the following query. FILEPATH is the name of the column. So far, it gives me the file name, but has the '-' in front of it. Can someone help me get rid of this. Thanks in advance.

    Select substr(FILEPATH, (instr(FILEPATH,'\',-1,1)))
    from Table_Name
    where ID = '101'
    
    

    Hello

    Here's one way:

    SELECT SUBSTR (FilePath

    INSTR (FilePath

    , '\'

    -1

    ) T

    ) + 1 + 1 in the end note

    ) AS file_name_only

    Table_Name FROM

    ID WHERE = '101'

    ;

    SUBSTR (str, p) returns the last part of the string str, starting at position p.  You place the position of the last '-' p; That's why the ' \' was added.  If you add 1 backwards, like this:

    SUBSTR (str, p + 1) then you're going to be in the way of the position of the character after the last 1 '-'.

  • Find key words in a string using substr

    Hello

    I have following values in a column.
    uspa-doj-brnz-INT1_SCS_ASCS_DATA-int-m
    uspa-doj-brnz-PRD_SCS_ASCS_APP-int-m
    uspa-doj-brnz-DEV1_SCS_ASCS_DATA2-int-m
    .
    .
    .
    .
    I would like to get help from the following keywords before the the first character "_" and the third "-" character. Something like that.
    INT1
    PRD
    DEV1
    .
    .
    .
    I made the next attempt. It seems that it works, but I want to know if there is a better way.
    substr(regexp_substr(col1, '[^_]+', 1, 1), 15)
    Thank you
    -Abe

    Published by: abe50 on Sep 10, 2012 15:27

    abe50 wrote:
    I would like to get help from the following keywords before the the first character "_" and the third "-" character. Something like that.
    ...
    I made the next attempt. It seems that it works, but I want to know if there is a better way.

    substr(regexp_substr(col1, '[^_]+', 1, 1), 15)
    

    Your version is based on the fact that the first 3 - indications always take up to 15 characters. If this is not guaranteed, so an expression like that could be better.

    with testdata as (select 'uspa-doj-brnz-INT1_SCS_ASCS_DATA-int-m' col1 from dual union all
                      select 'uspa-doj-brnz-PRD_SCS_ASCS_APP-int-m' col1 from dual union all
                      select 'uspa-doj-brnz-DEV1_SCS_ASCS_DATA2-int-m' col1 from dual union all
                      select 'uspa2-doj-brnz-DEV1_SCS_ASCS_DATA2-int-m' col1 from dual )
    select col1,
           substr(regexp_substr(col1, '[^_]+', 1, 1), 15) original,
           regexp_replace(col1, '^([^-]+-){3}([^_]+)_.+$', '\2') regexp_only
    from testdata
    
    COL1                                     ORIGINAL          REGEXP_ONLY
    ---------------------------------------- --------------------------
    uspa-doj-brnz-INT1_SCS_ASCS_DATA-int-m   INT1                       INT1
    uspa-doj-brnz-PRD_SCS_ASCS_APP-int-m     PRD                        PRD
    uspa-doj-brnz-DEV1_SCS_ASCS_DATA2-int-m  DEV1                       DEV1
    uspa2-doj-brnz-DEV1_SCS_ASCS_DATA2-int-m -DEV1                      DEV1
    

    Or even (using a slightly different logic)

           regexp_substr(col1, '[^-_]+', 1, 4) 
    

    Published by: W. Sven 11 Sep, 2012 18:18

  • Use substring of paragraph &lt; $paratext &gt;?

    Hi all

    FM (we use version 11) allows any type of expressions in variables in order to extract a substring of a paragraph for use in a M/F run? I studied him this as much as possible and I did a search on the forum and the first reactions look promising, although these responses seem to be for older versions...

    An example would be a paragraph that looks like this:

    Tropical Island - a wonderful place to be

    and we only get out

    Tropical Island

    for M/F running so that we can take advantage of the automatic filling of FM of the header on left pages similar to a dictionary using < [MyTag] $paratext > and < $paratext [+ MyTag] >, only this MyTag is the substring of the paragraph, not the whole paragraph.

    I am very grateful for any help or suggestion.

    Thank you!

    Using Extendscript (or Framescript) would be the way to go, if you have a way to uniquely identify the fractional part of the paragraph text that you need.

    On the feature of expression, how you imagine it works on the FM band? A regex expression any? The content will always be pretty unique to get the desired match?

    Note: If you head titles were of the type "point - descriptor", then you might have used two separte paratags in Run-in mode to make it homogeneous, but still allow you to use the building blocks <$paratext[...]>.

  • Optimize the query using SUBSTR

    Hi, I wrote the following to get the string 'abc' in the following input strings


    ' 2010/abc' and
    ' 2010/inv/abc '.

    I have to get the string ("abc") that is after the last ' / '.
    In the entrance of the channels the ' / ' can be 1 or 2

    So I tried the following
    select substr(substr('2010/abc',(instr('2010/abc','/',1,1)+1),length('2010/abc inst')),
    (instr(substr('2010/abc',(instr('2010/abc','/',1,1)+1),length('2010/abc inst')),
    '/',1,1)+1),length (substr('2010/abc',(instr('2010/abc','/',1,1)+1),length('2010/abc inst')))) str from dual
    The Select query above is even working for the string "abc/2010/inv" (until the 2nd "/" only it works)

    Could please minimize the above query, and which may even work you for same 3rd or 4th ' / '.


    Thank you

    Hello

    Alternatively, you can use regexp if you want:

    Scott@my10g SQL>l
      1  with data as (
      2  select '2010/abc' str from dual
      3  union all select 'inv/2010/abc' from dual
      4  union all select 'inv/2010/inv/2010/abc' from dual
      5  union all select 'abc' from dual
      6  )
      7* select str, regexp_substr(str,'[^/]+$') sstr from data
    Scott@my10g SQL>/
    
    STR                   SSTR
    --------------------- ----------
    2010/abc              abc
    inv/2010/abc          abc
    inv/2010/inv/2010/abc abc
    abc                   abc
    

    It would be up to the end of the string from the last source / (or early if no / in the source string)

  • REG USING SUBSTR

    I want out put like BOTTOM of BOTTOMBUD using susbtr finction.

    Can I use select substr ('BOTTOMBUD', 1, 6) of double; for a single word, but I want that whenever the last 3 letters excluded. in this case, they are BUD.

    I hope that I am clear on my question. Please suggest.

    TRY this SELECT substr ('BOTTOMBUD', 1, 6) FROM DUAL;

  • Using SUBSTR to convert part of an IP address to a NUMBER and then sort

    Hello!

    I have a table in APEX that IP numbers and was looking for a way to be able to sort out them.

    I wrote the following script:
    SELECT TO_NUMBER (SUBSTR (IP, 11)) y
    OF NETWORKINFO y
    ORDER BY y

    Which produces the results I'm looking for.

    However, I use the 'FORM ON A TABLE WITH REPORT' by their SUMMIT. It is perfect for what I need, but here's my question:

    How can I go about adding my custom SQL string to be able to use the feature to sort of this 'FORM ON A TABLE WITH REPORT "?

    In the above form, it gives the ability to sort by any column. Is there a way I could do a column hidden, associated with the IP column to sort results?

    Sorry if I'm not in all this that claire here - let me see if I can be more specific.

    I have the IP addresses which of course do not sort numerically. So I wrote the SQL script above to convert a portion of these IP addresses in a number format.

    Is it possible to combine the two in the search function in 'Form on a Table with report' so I can get a user sort by IP number, but behind the scenes it sorts using the SUBSTR value from above?

    Thank you for pointing me in the right direction on this subject!

    -Igor

    Hi Igor,.

    You can get a custom sort order added to your IP column without needing a second column.

    Consider that the sorting is done strictly from left to right across a string in the column. The string can be any content valid HTML. So you can wrap your string in, say, a SPAN tag and add an attribute to the tag that contains the sort order, you need to forward the text that is displayed to the user. As long as the attribute is properly structured (in other words, all instances are the same length, for example), then sort will work correctly. For example:

    SELECT
    '' || IP || '' Y
    FROM ...
    

    Now you must make sure that the PAD_IP_ADDRESS() function returns the correct values. In IP addresses, you have whatever it is "0.0.0.0" to "255.255.255.255". To sort "digitally", you need fill one or two numbers to get three numbers for each value of - so, "0.0.0.0" becomes "000.000.000.000." You can create a function to do this - something like:

    CREATE OR REPLACE FUNCTION PAD_IP_ADDRESS
    (
      pIP IN VARCHAR2
    )
    RETURN VARCHAR2
    IS
      vIP VARCHAR2(15);
      vTEMP APEX_APPLICATION_GLOBAL.VC_ARR2;
      vSEP VARCHAR2(1);
    BEGIN
      vSEP := '';
      vIP := '';
      vTEMP := APEX_UTIL.STRING_TO_TABLE(pIP,'.');
      FOR x IN 1..vTEMP.COUNT
      LOOP
        vIP := vIP || vSEP || TRIM(TO_CHAR(TO_NUMBER(vTEMP(x)),'000'));
        vSEP := '.';
      END LOOP;
      RETURN vIP;
    END;
    

    The result of this would look like:

    <span title="001.001.001.001">1.1.1.1</span>
    <span title="002.255.255.255">2.255.255.255</span>
    <span title="010.001.199.098">10.1.199.098</span>
    

    Andy

  • Using SUBSTR

    Hi all

    I use Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production.

    I have the XML_REC column in a table, and the value is lower.

    < placeOrder xmlns = "urn:org.kp.pc.placeOrder" > < delegateMrn >07950359< / delegateMrn > < status orderInfo = "SUCCESSFUL" > < guid > 177275 < / guid > < mOrderNum > 2015092617000025027981 < / mOrderNum > < orderNum > 2015092617000025027981 < / orderNum > < date > 20150927 < / date > < delivery > < type > US_MAIL < / type > < mailingAddress > < line1 > 5607 KIVA DRIVE < / line1 > < City > CARMICHAEL < / City > < State > CA < / State > < > 95608 zip < / zip > < singleUse > false < / singleUse > < / mailingAddress > < defaultAddress > < line1 > 5607 KIVA DRIVE < / line1 > < line2 > < / line2 > < City > CARMICHAEL < / City > < State > CA < / State > < > 95608 zip < / zip > < / defaultAddress > < / delivery > < / orderInfo > < rxData costSource = "historic cost". ': zero ' rc = "000" source = "Epic" statusCode = "00" > < MNR relationship 'auto' = >07950359< / MNR > < rx >2566804902< /RX > < rxPreOrderRxNum > 5915638866 < / rxPreOrderRxNum > < rxPostOrderRxNum > 2566804902 < / rxPostOrderRxNum > < nhinId > 0 < / nhinId > < sOrderNum > 2015092617000025027981 < / sOrderNum > < name > CLONAZEPAM 1 MG TABLETS < / name > < invalid > true < / ineligible items > < rxDispenseLocationCode > 591 < / rxDispenseLocationCode > < displayStatusCodes > PHE: 1000 < / displayStatusCodes > < approxReadyDate > 20151004 < / approxReadyDate > < / rxData > < / placeOrder >

    The query should return the value as below for the above values and also the order can vary for each value.

    DELEGATE_MRN MNR RXNUMBER

    7950359 7950359 2566804902


    Please, please help me on this.


    Thank you

    Maybe

    with

    As XMLDATA

    (select xmltype ('))

      0019295803

      4792958 Z2015092409004934

      Z2015092409004934

      20150924

     

        US_MAIL

       

         218 N SWEETWATER ST

         ANAHEIM

         CA

         92807

         fake

     

     

         218 N SWEETWATER ST

        

         ANAHEIM

         CA

         92807

     

     

     

     

          0019295803

          107006733859

          107006733859

         

          900001070

          Z2015092409004934

          SUMATRIPTAN 100 MG TAB SUNP

          true

          70

          PHE:1000

     

     

          0019295802

          175307282783

          175307282783

         

          900001753

          Z2015092409004934

          RATED 3 MG / 24 H CAP BUDESONIDE

          true

          753

          PHE:1000

     

    donnees_xml ')

    of the double

    )

    Select x.*

    of xmldata xd.

    XMLTable (xmlnamespaces (default ' urn:org.kp.pc.placeOrder'),

    "Let's $po: = /placeOrder."

    for $i in $po / rxData

    return

                    

                        {$po/delegateMrn}

                        {$i / MNR}

                        {$i / rx}

                    

    '

    in passing xd.xml_data

    path of columns delegate_mrn varchar2 (20) "/ ESA/delegateMrn,"

    path of varchar2 (20) MNR "/ ESA/MNR."

    path of varchar2 (20) RX ' / ESA/rx '

    ) x

    DELEGATE_MRN MRN RX
    0019295803 0019295803 107006733859
    0019295803 0019295802 175307282783

    Concerning

    Etbin

Maybe you are looking for

  • Satellite C855D-124 does not start - black screen

    Hello I have a problem on my PC (by Satellite C855D-124) specifically was playing a game, and stopped from nowhere I could not do any command then off button. But as I returned the call and turned the lights appeared as the charge appears as a small

  • Restore Partion D should be lit

    Pavilion G7, Windows 8. The player named ' RECOVERY (D indicates that the PROTECTION is DISABLED.). Is it OK or should I turn it on? Protection is enabled for Local disc (C (System)) Thank you

  • Cannot pin or loose most of the things from the taskbar / / Win7

    Hi people, I have an apparently strange issue where I can't PIN or loose most of the things in my taskbar. The generic search has many similar situations but none of them seemed exactly the same and none of the listed solutions worked for me or seeme

  • The manual says I can connect speakers or headphones to my headphones Jack (SVF15A1).

    My VAIO SVF15A1 has a headphone jack (I guess that's a tip-ring-ring-sleve SOCKET configuration).  The manual says I can connect speakers or headphones to this Jack, but the speakers and headphones usually have the usual configuration of TRS stereo (

  • EAM_Analytics ETL run hangs

    HelloRecently, we changed our source ETL server. (love of Server1 Server2) the same version and same operating system. I configured the physical data sources and all the other connection strings to point to server2. Now, I am trying to run the EAM_An