Return distinct values in a fuction

Hi all

I create a function, where it must take two parameters of the input string and return the distinct values of the two channels

input parameters are: 2.71A2, 2.71X15, 2.71x15 and 2.71A2, 2.71X15, 2.71a2

I get the output as 2.71A2 parameters, 2.71X15

need to convert lower case to upper case and compare.

post needed more information.

Thank you.

One way is:

Select listagg (ds, ",") the Group (control 1)

from (select distinct superior (REGEXP_SUBSTR (s, "[^,] +', 1, rownum")) ds)

from (select '2.71A2, 2.71X15, 2.71x15, 2.71A2, 2.71X15, 2.71a2's)

the double)

connect by INSTR (s, ',', 1, level - 1) > 0

and prior sys_guid() is not null)

Another way xmlquery

----

Ramin Hashimzade

Tags: Database

Similar Questions

  • you place your order in xquery-distinct values

    I was surprised to see the return of the following different results, is this a bug in the XML Query rewrite, or is the order of not only guaranteed the distinct values?

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

    With partitioning, OLAP, Data Mining and Real Application Testing options

    SQL > SELECT XMLQUERY)

    2 ' (string code points

    3 distinct-values ((99,98,97)))'

    4 ELECTION CONTENT) result

    5 FROM dual;

    RESULT

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

    ABC

    SQL > SELECT / * + NO_XML_QUERY_REWRITE * /.

    () 2 XMLQUERY

    3 ' (string code points

    distinct-values ((99,98,97))) 4'

    5 ELECTION CONTENT) result

    6 FROM dual;

    RESULT

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

    CBA

    SQL >

    Hello

    The specs say the order is "dependent application": fn: distinct values

    Summary so is (I guess), strict language point of view, should not rest on any apparent order in the resulting sequence.

    The results collected by the two queries probably be different for the same reason: different implementation.

    First one with XQuery Rewrite active is solved using the SQL operators and functions, something along these lines:

    SELECT 'CODEPOINT2STR_FUNC' ('SEQUENCE')

    DE)

    SELECT 'AGGREGATE_FUNC' (VALUE (T) SEPARATE) "SEQUENCES".

    TABLE ("SEQUENCE_FUNC"(99, 98, 97)) T

    ) ;

    While the second is evaluated by the XVM and apparently maintains the original order.

  • XML - ORA-19025: EXTRACTVALUE returns the value of a single node

    Hello

    I'm new to XML DB. Can someone help me with the below XML

    I use the following XML... (I pasted a part only of it coz I need data only up to this article)

    XML
    --------------------

    <? XML version = "1.0" encoding = "UTF-8"? > < SOAP - ENV:Envelope xmlns:SOAP - ENV = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-."
    example"container ="http://www.w3.org/2001/XMLSchema"> < SOAP - ENV:Body >
    < ns:PicklistWS_GetPicklistValues_Output xmlns:ns = "urn: crmondemand/ws/list dropdown /" >
    < ListOfParentPicklistValue xmlns = "urn: / xml/crmondemand/list of choices" >
    < ParentPicklistValue >
    < language > ENU < / language >
    < ParentFieldName > plProduct_Team < / ParentFieldName >
    < ParentDisplayValue > Marketing On Demand < / ParentDisplayValue >
    < ParentCode > Marketing On Demand < / ParentCode >
    < Disabled > N < / disabled >
    < ListOfPicklistValue >
    < PicklistValue >
    Escalation of OCP/SME < code > < code >
    Escalation of OCP/SME < DisplayValue > < / DisplayValue >
    < Disabled > N < / disabled >
    < / PicklistValue >
    < PicklistValue >
    Ask fusion < code > < code >
    Merge request < DisplayValue > < / DisplayValue >
    < Disabled > N < / disabled >
    < / PicklistValue >



    Code
    ---------




    SELECT distinct
    EXTRACTVALUE (value (SR), ' / ParentPicklistValue/ListOfPicklistValue/PicklistValue/Code ','xmlns = "urn: / crmondemand/xml/list of choices"') AS display.
    Return EXTRACTVALUE (value (SR),'/ ParentPicklistValue/ListOfPicklistValue/PicklistValue/DisplayValue ',' xmlns = "urn: / crmondemand/XML/picklist"'),.
    EXTRACTVALUE (value (SR), '/ ParentPicklistValue/ParentDisplayValue','xmlns = "urn: / crmondemand/XML/picklist"') AS parent_display,
    EXTRACTVALUE (value (SR), '/ ParentPicklistValue/ParentCode','xmlns = "urn: / crmondemand/XML/picklist"') AS parent_return
    TABLE (XMLSEQUENCE ((EXCERPT)
    WEB_SERVICE (' <? xml version = "1.0" encoding = "UTF - 8" standalone = "no"? > < envelope soap: xmlns:soap = "http://schemas.xmlsoap.org/soap/envelope/")
    xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" container = "http://www.w3.org/2001/XMLSchema" >
    < soap: Body >
    < PicklistWS_GetPicklistValues_Input xmlns = "urn: crmondemand/ws/list dropdown /" >
    Type < FieldName > < / FieldName >
    Service request < RecordType > < / RecordType >
    < / PicklistWS_GetPicklistValues_Input >
    < / soap: Body >
    "< / envelope soap: >.
    (' document / urn: crmondemand/ws/list dropdown /: ' GetPicklistValues, Id_de_la_session).
    "/: soap envelope / soap: Body / * / * / * ',' xmlns:soap ="(http://schemas.xmlsoap.org/soap/envelope/'))) SR "


    ERROR
    ---------

    ORA-19025: EXTRACTVALUE returns the value of a single node


    UNDERSTANDING
    ---------------------------

    As my Xpath only points until the node - ParentPicklistValue and not the child nodes under it. That's why, when I try to interview the child nodes - / ParentPicklistValue/ListOfPicklistValue/PicklistValue/Code, I get the error mentioned above.

    REQUIREMENT
    -----------------------

    Can someone help me to receive the values of the mother and child values based on xml and query above.

    Hello

    It's a classic ;)

    You need a second XMLSequence who shreds the collection of PicklistValue in relational lines:

    select extractvalue(value(sr2), '/PicklistValue/Code', 'xmlns="urn:/crmondemand/xml/picklist"') AS Display
         , extractvalue(value(sr2), '/PicklistValue/DisplayValue', 'xmlns="urn:/crmondemand/xml/picklist"') AS Return
         , extractvalue(value(sr1), '/ParentPicklistValue/ParentDisplayValue', 'xmlns="urn:/crmondemand/xml/picklist"') AS parent_display
         , extractvalue(value(sr1), '/ParentPicklistValue/ParentCode', 'xmlns="urn:/crmondemand/xml/picklist"') AS parent_return
    from table(
           xmlsequence(
             extract( WEB_SERVICE( ... )
                    , '/soap:Envelope/soap:Body/ns:PicklistWS_GetPicklistValues_Output/ListOfParentPicklistValue/ParentPicklistValue'
                    , 'xmlns="urn:/crmondemand/xml/picklist"
                       xmlns:ns="urn:crmondemand/ws/picklist/"
                       xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' )
           )
         ) sr1
       , table(
           xmlsequence(
             extract( value(sr1)
                    , '/ParentPicklistValue/ListOfPicklistValue/PicklistValue'
                    , 'xmlns="urn:/crmondemand/xml/picklist"' )
           )
         ) sr2
    ;
    

    What is your version of the database BTW?
    10.2 and upward, you can use the XMLTable.

  • XQuery to return separate values in xml

    Hello
    I have a requirement where I have to get distinct values from an xml file.

    EX: entry

    <? XML version = "1.0" encoding = "UTF-8" standalone = "yes"? >
    < Hand xmlns = "http://www.abc.org.com/FormDetails" >
    < abcd first = '1' second = "2" / >
    < fruit >
    < name of fruit = "banana" color = "green" >
    < name of fruits = "apple" color = "red" >
    < name of fruit = "grape" color = "green" >
    < name of fruits = "apple" color = "red" >
    < name of fruit = "banana" color = "green" >
    < name of fruits = "apple" color = "red" >
    < name of fruit = "grape" color = "green" >
    < name of fruit = 'orange' color 'orange' = >
    < name of fruit "lemon" color = "yellow" = >
    < / fruit >
    < fruit >
    < name of fruit = "banana" color = "green" >
    < name of fruits = "apple" color = "red" >
    < name of fruit = "grape" color = "green" >
    < name of fruits = "apple" color = "red" >
    < name of fruit = "banana" color = "green" >
    < name of fruits = "apple" color = "red" >
    < name of fruit = "grape" color = "green" >
    < name of fruit = 'orange' color 'orange' = >
    < name of fruit "lemon" color = "yellow" = >
    < / fruit >
    < fruit >
    < name of fruit = "banana" color = "green" >
    < name of fruits = "apple" color = "red" >
    < name of fruit = "grape" color = "green" >
    < name of fruits = "apple" color = "red" >
    < name of fruit = "banana" color = "green" >
    < name of fruits = "apple" color = "red" >
    < name of fruit = "grape" color = "green" >
    < name of fruit = 'orange' color 'orange' = >
    < name of fruit "lemon" color = "yellow" = >
    < / fruit >
    < / hand >

    Required output: String

    banana = Green | Apple = Red | grape = Green | Orange = orange | lemon = yellow

    I used this xquery:

    declare namespace xf = "http://tempuri.org/abcorg/Transformations/Distinct_Fruits/";
    declare namespace ns = "http://www.abc.org.com/FormDetails";


    declare function xf:Distinct_Fruits ($fruits as element (ns:Main))
    as XS: String {}


    for $d in distinct-values ($fruits//ns:fruit/@name)
    return "{$d} ="

    for $e in distinct-values ($fruits//ns:fruit/@color)
    return "{$e}"

    };


    declare the external $fruitsas element(ns:Main) variable;

    XF:Distinct_Member ($fruits)



    I get an error message like:

    The transformation of XQuery runtime error: line 11, column 1: {err} FORG0005: expected exactly a single element, 2 + items


    Please let me know where it went wrong.


    Thank you...

    Published by: user12679330 on July 12, 2011 04:47

    The second example (using the previous and deep brother on equality) will not work if there are several elements of "fruit".
    I will post later the adapted version.

    Here it is:

    declare function xf:Distinct_Fruits( $fruits as element(Fruits)* )
    as xs:string
    {
     string-join(
       for $i at $p in $fruits/fruit
       let $f := $i[not(some $x in $fruits/fruit[position()<$p] satisfies fn:deep-equal($x,.))]
       where ($f)
       return concat($f/@name, " = ", $f/@color)
     , "|"
     )
    };
    

    I replaced the preceding-sibling axis with a set of nodes of all the fruits before the current position.

  • How to return the value 0 for no data using the County?

    Hi all
    I used this query to count the number of records for each month of the year:

    SELECT DISTINCT COUNT (I.information_sid) COUNT, TO_DATE (TO_CHAR (INSERT_DATE, 'MM'), 'MM') MONTH

    INFORMATION I

    TO_DATE GROUP (TO_CHAR (INSERT_DATE, 'MM'), 'MM')

    ORDER BY TO_DATE (TO_CHAR (INSERT_DATE, 'MM'), 'MM')

    But this code returns no value for months without data
    I want to return the value '0' for any month of data. How, please?

    Note: I use reports 6i.

    Maybe this?

    SELECT SUM(CNT_REC) CNT_REC, MONTH
    FROM
    (
    SELECT COUNT(I.information_sid) CNT_REC, TO_DATE(TO_CHAR(INSERT_DATE,'MM'),'MM') MONTH
    FROM INFORMATIONS I
    GROUP BY TO_DATE(TO_CHAR(INSERT_DATE,'MM'),'MM')
    UNION ALL
    SELECT 0, LPAD(ROWNUM,2,0)
    FROM ALL_OBJECTS
    WHERE ROWNUM <= 12
    )
    GROUP BY MONTH
    ORDER BY MONTH
    

    No need to SEPARATE during the use of GROUP BY.

    -Clément

  • distinct values Ansdo_elem_info

    Hello

    How do I get distinct values in Ansdo_elem_info. I tried now but no luck. (I'm looking for different values in sdo_elem_info_array)

    Select * from parcels p
    where p.geometry.SDO_ELEM_INFO = mdsys.sdo_elem_info_array (1,1003,1)

    get "ora-00932 inconsistent data types: planned mdsys.sdo_elem_info_array had.

    Thank you
    Ramiz

    Hello
    I don't think you can compare two varrays using (=).
    You can use a PL/SQL function (as below) to achieve this.

    Select... from [your_table]
    where same_elem_info_array (array1, array2) = "TRUE";

    Jack

    create or replace function same_elem_info_array (array1 in mdsys.sdo_elem_info_array, in mdsys.sdo_elem_info_array array2)
    VARCHAR2 is back
    Start

    If (array1 is null or)
    Array2 is null) then
    Returns a null value.
    end if;

    If (array1.count! = array2.count) then
    Back to "FALSE";
    end if;

    because me in 1.array1.count
    loop
    If (array1 (i)! = array2 (i)) then
    Back to "FALSE";
    end if;
    end loop;

    Returns "TRUE".

    end same_elem_info_array;
    /

  • meter returns garbage values

    I use cDAQ 9184 and 9401 digital I/o card, I use the counters available for the measurement of the frequency (pulses are generated by a sensor hall, whose frequency I want to measure to estimate the speed of the motor DC.) But the problem is that this counter returns garbage values. I tested the card and its counters that they are working correctly. What could be the possible causes of what is happening?

    attach a snapshot of the VI.
    Please hep out me as soon as possible.

    Thank you and best regards.

    Are these garbage values much higher frequency than you expect?  If so, you're probably picking up noise and should allow the filter PFI for your task.

    Best regards

  • Guest user does not return a value

    I have a user prompt dialog box which is a slightly modified version of questioning the standard user to enter VI express. I tried to change the VI so that it would allow the user to close the command prompt by pressing the enter/return key. The final objective is to have the popup dialog, the user will scan a bar code and barcode reader adds a carriage return, automatic closing of the dialog box character.

    I have followed this user lyrics: https://decibel.ni.com/content/docs/DOC-13973. The only difference between my code and the code it is that my user dialog box returns a string instead of a number. See below for my code.

    The problem that I am running is the string "Item number2" never really returns any value once it's called. The indicator on the front panel of the updated the express vi displays the correct value after you run, but the value is never returned to the VI, who called the dialog box. The express vi the value default value is successfully returned. The only change I made was the addition of the structure of the event, so I have to assume that my code does not go inside this node.

    Any thoughts are appreciated.

    Adjust the chain drive on 'Update value then of the hit'.

  • Line tool command that returns a value

    Is it possible to compile a VI to work as a tool of command line that accepts arguments and returns a value? I need to create commands that will be run from a shell script and return values that will be used in the script in order to evaluate the results. If possible, the type and the range of values can be returned? I've seen a few posts on the masking of the façade, but none on the return a value to the shell of the appellant.

    Andrey,

    Thanks for your help. The only thing missing from your response to me was that I use c#. In this case, you simply have to add code to manage a DLL unmanaged like this:

    using System.Runtime.InteropServices;

    public class Win32

    {

    [DllImport ("Drive Letter: \\path to dll\\DLL Name.Dll")]

    public static extern double Testing();

    }

    After you have added this code to import the DLL in a class of your choice, you can call the function to run the LabVIEW VI library.

    Best regards

    Timothy

  • bbUI.js and localStorage.getItem return null values

    Hello

    I build a WebWorks app with bbUI.js for BB10 and I run problems when I want to retrieve items of localStorage. Their storage is no problem. Here is my architecture:

    1. index.html which uses localStorage.getItem in a function ondomready for 1 screen (fueltracker.html), it works
    2. JS/Register.js with functions like registerUser(), registerEngine(), registerBrand(), registerModel() called when onclick in their respective screens, see below
    3. RegisterUser() calls register.html
    4. registerBrand() calls addCar.html
    5. registerModel() calls addModel.html
    6. registerEngine() calls addEngine.html
    7. fueltracker.html which has a few buttons that the label should be changed to values from localStorage

    The register() functions make a call to localStorage.setItem (), working (i.e. the values are defined). However, in some cases parts of objects stored in localStorage it update, so this object must be recovered first, updated and then stored again. Unfortunately the calls localStorage.getItem () does not return the value that is stored in the localStorage.

    So how does it do?

    Yes Chad, variables have been established.

    It's the same problem as this one: http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage (objects cannot be stored in LocalStorage, single key-value pairs, so items must be chained before putting them in the LocalStorage). The getObject() en index.html setObject methods and their use instead of getItem() and setItem() solved the problem.

  • Function return undefined values

    My function returns undefined values. It seems that the return of the function statement is executed before the database is queried and values are assigned to variables. If I do an alert within the loop for () I get the correct values from the database, but these values are not affected before excecuting the return statement function. How can I do this differently?

    function getColumnNames(table){
        var rs1, rs2, rs3, rs4, rs5;
        db.transaction(function (tx) {
            tx.executeSql("SELECT * FROM schema WHERE table_name=?",[table], function(ax, results){
                var size = results.rows.length, i;
                var item;
                for (i = 0; i < size; i++){
                    item = results.rows.item(i);
                    rs1 = item.col1;
                    rs2 = item.col2;
                    rs3 = item.col3;
                    rs4 = item.col4;
                    rs5 = item.col5;
                                    alert(rs1); //correct value is returned here
                }
            });
        });
        return [rs1, rs2, rs3, rs4, rs5];
    }
    

    Hey Fabian,.

    You are quite correct that the return statement is executed before the database returns the results. There are ongoing asynchronous calls. You can set breakpoints in JavaScript code to see what is happening. You can correct the problem by using function callbacks. I edited your code below to use the callback functions - there might be a few typos, but the general approach should be wooded.

    function getColumnNames(table, callback){
        var rs1, rs2, rs3, rs4, rs5;
        db.transaction(function (tx) {
            tx.executeSql("SELECT * FROM schema WHERE table_name=?",[table], function(ax, results){
                var size = results.rows.length, i;
                var item;
                for (i = 0; i < size; i++){
                    item = results.rows.item(i);
                    rs1 = item.col1;
                    rs2 = item.col2;
                    rs3 = item.col3;
                    rs4 = item.col4;
                    rs5 = item.col5;
                        alert(rs5); //correct values are being returned
                    callback([rs1, rs2, rs3, rs4, rs5]);
                }
            });
        });
    }
    
    // example of how to call getColumnNames with callback
    getColumnNames('importantTable', function (result)
    {
        console.log(result);
    });
    
    // alternative version
    function onCallback(result)
    {
        console.log(result);
    }
    
    getColumnNames('importantTable', onCallback);
    

    I hope this helps.

    See you soon,.

    James

  • COS() returning incorrect values

    Hi, anyone of you tried get values of cos() to native c++... ? It seems that sin values are correct, but the cos returns incorrect values. As for example, sin(pi/2) Returns infinity. No idea what could be wrong?

    @SuhairZain,

    #include 
    #include 
    int main(void)
    {
            float pi = 3.14159265f;
            printf("Result: %f\n", sin(pi/2));
    }
    

    Result: 1.000000

  • Do stuff to PL/SQl that returns the value and redirect to modal page by setting this value

    Hello

    a button click Page1 I would perform a PL/SQL procedure that returns a value in P1_ITEMVAL and then redirect to a page 2 (modal page) and the value of an item on this page with the value previously returned. To do the same thing with a normal page is quite easy:

    Button action is present, then process of PL/SQL that returns the value in the P1_ITEMVAL element and, finally, a branch at page 2 that sets P2_ITEMVAL with P1_ITEMVAL. I really have no idea how to do the same thing when the target is a modal page.

    I created a unit test on https://apex.oracle.com/pls/apex (application 1554 - redir_to_modal)

    Workspace: tests

    USER: supporter

    PWD: supporter1234

    Any help would be much appreciated.

    Kind regards

    Pavel

    Pavel

    If you prepare a URL using the value calculated in the PLSQL of DA part you can then use a subsequent stage of javascript to set the location of the window.

    This will jump to the top of the page of the modal dialog box

    : P1_URL: = apex_util.prepare_url)

    ' f ? p ='|| : APP_ID - Application id

    |': 2' - Page id

    ||': ' || : APP_SESSION - Session id

    ||':'                      -- Request

    ||':NO'                    -- Debug

    : ': ' - Clear Cache

    : ': ' - Settings

    ||' P2_ITEMVAL'

    : ': ' - Parameter values

    || (: P1_ITEMVAL);

    then in the action of javascript

    Window.Location.Replace ($v ('P1_URL'));

    Hope this is of some use

    Concerning

    Kelvin

  • Cannot return a value in LOV

    Dear all,

    I have create a LOV in my code field that is a primary key at my table. And I can't return the value from the lov,

    I get the below error.

    oracle.jbo.InvalidOperException: Houston-29114 ADFContext is not configured to process this exception messages. Use the code of exception stack trace and error to investigate the root cause of this exception. Root cause error code is Houston-34014. Error messages settings are {0 = oracle.jbo.Key [null A9], 1 = root}

    Please note that am I 1 primary key with 2 field in my table.

    And note that use jdev 12.1.3

    Another solution...!

    There is always another solution:

    -' they' can remain on Oracle Forms and forget ADF

    -' they' can refine their requirements to equip the technical constraints of the ADF

    -' they' can use some other technologies instead of the ADF

    Dario

  • Show only distinct values in narrative mode

    Hi guys!

    Here again, we are trying to reach an ambitious goal.

    It is possible to show only distinct values in a narrative view? For example, I have a query that retrieves about 100 lines. In these lines, a few different years, it is something like this:

    1-2013, Jhon, 10

    2-2013, Brian, 15

    3-2013, Pete, 20

    ...

    10-2014, Steve. 5

    11-2014, Kevin, 12

    ...

    90-2015, Ray, 24

    91-2015, Michael, 2

    ...

    It is possible a mode display narrative only something like that?

    Years: 2013, 2014, 2015

    If I use the feature number @column, I get as many years the results are retrieved. It is not user friendly.

    Any help will be appreciated.

    Best regards

    Fabian

    Hi all!

    I found my own solution and I want to share with you. Maybe it helps someone in the future.

    I used JavaScript to iterate through each row value. By each line, I'll check if it value is added to the overall picture with unique values. If not added, I add it, otherwise, I do nothing.

    Here is my script (pay attention to each code block, it must be in its proper "narrative class"):

    Narrative section prefix

Maybe you are looking for

  • Re: Usb3 1 TB Canvio and Macbook Pro

    Hi there, after you fix the issue I had with my Macbook Pro using an extension cable USB 2 drive decided to stop working suddenly and will not be displayed in Lion The player will turn up then click loudly, spin up and click loudly and will continue

  • Photon: Everybody just restarts randomly?

    Just bought Sunday and the continuous phone rebooting randomly, that this service or not. I wouldn't return the phone, RAM evil the only possible problem and can only be isolated to my device and the user Photon4g? Get a new device solve the problem?

  • How to make windows media player to read rar files

    How to make windows media player to read rar files

  • What is the maximum memory a Presario V6719 accept?

    " Compaq Presario V6719NR Notebook PC Serial number: CNF8023MQ6 product number (P/N):KC550UA Operating system: Microsoft Windows Vista (32-bit) How much is the max memory?   I get conflicting information.

  • Critical hard drive put in custody and loss of blue screen

    I lost my blue screen and get warnings re critical threats of damage from hard drive and virus (trogen horse) however no virus detected on a scan from windows? warnins continually pop up.