XMLAttribute, incapable of managing multiple values returned from a query

Hi guys,.

I have to design the format of the return data from a query in XML format. For this I used the xmlelement and xmlattribute

the query goes like this



SELECT ' <? XML version = "1.0"? > ' | ' '|| XMLELEMENT ("imageData",
XMLATTRIBUTES (LI. GROUPNO as "imageName", "PNG'as"imageType"," 2.0 "as 'version', 'com.snapon.sbs' as 'xmlns'), '"
XMLELEMENT ("legends",
XMLATTRIBUTES (roundedRectangle as a 'form'),
XMLELEMENT ("caption",
XMLATTRIBUTES ((SELECT IO. PFEALIOCR IO PNC_KEYNO WHERE IO. BASECATALOGNO = LI. BASECATALOGNO AND LI. GROUPNO = IO. (GROUPNO) as 'label').
XMLELEMENT ("point",
XMLATTRIBUTES ((SELECT IO. COORDINATESX1 OF PFEALIOCR IO WHERE IO. BASECATALOGNO = LI. BASECATALOGNO AND LI. GROUPNO = IO. GROUPNO) as 'x', (SELECT IO. COORDINATESY1 OF PFEALIOCR IO WHERE IO. BASECATALOGNO = LI. BASECATALOGNO AND LI. GROUPNO = IO. GROUPNO) as "y")))
LI PFEALIGIL
WHERE LI. DELETEFLAG <>would be"

here a logical is a groupno of pfealigil and the corresponding pnc_keyno associated with groupno are read here. but here, given that several pnc_keyno are back xmlattributes is unable to manage. I want to design the xml code in this format

<? XML version = "1.0"? >
< imageData imageName = "ISDH0001104."
imageType = "PNG" version = "2.0" xmlns = "com.snapon.sbs" >
< legends form 'roundedRectangle' = >
< legend label = "182" >
< point x = "289" y = "' 68" / >
< / legend >
< legend label = "247" < point x = "430" y = "83" / >
< / legend >
< legend label = "122" > < point x = "546" y = "331" / >
< / legend >
< legend label = "249" > < point "402" = x y = "429" / >
< / legend >
< legend label = "248" > < point x = "392" y = "463" / >
< / legend >
< legend label = "182" > < point x = "228" y = "416" / >
< / legend >
< legend label = "1" > < point x = "364" y = "737" / >
< / legend >
< legend label = "14" > < point "494" = x y = "980" / >
< / legend >
< legend label = "168" > < point x = "671" y = "910" / >
< / legend >
< legend label = "15" > < point x = "779" y = "848" / >
< / legend >
< legend label = "1" > < point x = "805" y = "343" / >
< / legend >
< / legends >
< / imageData >


as here a picture name all these pnc_keyno which are valid should come this way as above. Please let me know if something is not clear for you

apexStarter wrote:
Data model goes like this

You talked about two tables in your first post, but I guess it's just a matter of to join them to get the above result set?

In this case you can do it like this:

SQL> WITH sample_data AS (
  2    SELECT '91-921' groupno, '1125AE' pnc_keyno, 000000127 coordinatesx1, 000000730 coordinatesy1 FROM dual UNION ALL
  3    SELECT '91-921', '18642F', 000000513, 000000891 FROM dual UNION ALL
  4    SELECT '91-921', '18643D', 000000620, 000000844 FROM dual UNION ALL
  5    SELECT '91-921', '18649E', 000000561, 000000688 FROM dual UNION ALL
  6    SELECT '91-921', '18668B', 000000620, 000000864 FROM dual UNION ALL
  7    SELECT '91-921', '92101A', 000000587, 000000591 FROM dual UNION ALL
  8    SELECT '91-921', '92102A', 000000587, 000000571 FROM dual UNION ALL
  9    SELECT '91-924', '1243BD', 000000617, 000000889 FROM dual
 10  )
 11  SELECT XMLRoot(
 12           XMLElement("imageData",
 13             XMLAttributes(
 14               groupno as "imageName"
 15             , 'PNG'as "imageType"
 16             , '2.0' as "version"
 17             , 'com.snapon.sbs' as "xmlns"
 18             )
 19           , XMLElement("callouts",
 20               XMLAttributes('roundedRectangle' as "shape")
 21             , XMLAgg(
 22                 XMLElement("callout",
 23                   XMLAttributes(pnc_keyno as "label")
 24                 , XMLElement("point",
 25                     XMLAttributes(
 26                       coordinatesx1 as "x"
 27                     , coordinatesy1 as "y"
 28                     )
 29                   )
 30                 )
 31               )
 32             )
 33           )
 34         , version '1.0'
 35         )
 36  FROM sample_data
 37  GROUP BY groupno
 38  ;

XMLROOT(XMLELEMENT("IMAGEDATA",XMLATTRIBUTES(GROUPNOAS"IMAGENAME",'PNG'AS"IMAGETYPE",'2.0'AS"VERSION",'COM.SNAPON.SBS'AS
------------------------------------------------------------------------------------------------------------------------


  
    
      
    
    
      
    
    
      
    
    
      
    
    
      
    
    
      
    
    
      
    
  




  
    
      
    
  

Tags: Database

Similar Questions

  • How can I get multiple results returned from a function

    IDBASKET IDSTAGE DTSTAGE
    ---------- ---------- ---------
    3 1 24 JANUARY 03
    3 5 25 JANUARY 03
    4 1 13 FEBRUARY 03
    4 5 13 FEBRUARY 03
    5 3 21 FEBRUARY 03


    I have entry is a unique number of the IDBASKET in this table and this feature works very well that if she has an IDSTAGE by idbasket. (idbasket #5)
    But how do I return a result for an IDBASKET when there several IDSTAGE? (idbasket #3 & 4)
    Thank you very much
    CARPET


    SQL > CREATE or REPLACE FUNCTION status_desc_sf
    2 (NUMBER Code_P)
    3 RETURN VARCHAR2
    4 EAST
    5 lv_output_txt VARCHAR2 (30);
    6 BEGIN
    7. If Code_P = 1 THEN lv_output_txt: = "Command" submitted
    8 ELSIF Code_P = 2 THEN lv_output_txt: = "Accepted, sent to the navigation";
    9 ELSIF Code_P = 3 THEN lv_output_txt: = 'out of stock ';
    10 ELSIF Code_P = 4 THEN lv_output_txt: = "Cancelled";
    11 ELSIF Code_P = 5 THEN lv_output_txt: = "shipped";
    12 lv_output_txt ELSE: not = 'no information ';
    13 END IF;
    14 lv_output_txt of RETURN;
    15 END;
    16.

    I think that your function works as expected, not necessary as you like it is running.
    See the example:

    SQL> create table t11(c1 int, c2 int)
      2  /
    
    Table created.
    
    SQL> insert into t11(c1,c2) values(1,1);
    
    1 row created.
    
    SQL> insert into t11(c1,c2) values(1,2);
    
    1 row created.
    
    SQL> insert into t11(c1,c2) values(2,2);
    
    1 row created.
    
    SQL> create or replace function func2(p_code number)
      2  return varchar2
      3  is
      4  v_output varchar2(64);
      5  begin
      6  if p_code = 1 then
      7     v_output := 'Submitted';
      8  elsif p_code = 2 then
      9     v_output := 'Accepted';
     10  end if;
     11  return v_output;
     12  end func2;
     13  /
    
    Function created.
    
    SQL> /
    
            C1 test
    ---------- ------------------------------
             1 Submitted
             1 Accepted
             2 Accepted
    

    If you have run the function in a manner similar to mine, it will work for all ranks. Your design of the table shows that keep you track of each State of your order, so you have more than one State of each basket. If you want to view only the last State of each basket, please take a look at this example:

    SQL> alter table t11 add c3 date
      2  /
    
    Table altered.
    
    SQL> update t11 set c3 = sysdate - 1 where c1 = 1 and c2 = 1
      2  /
    
    1 row updated.
    
    SQL> update t11 set c3 = sysdate  where c1 = 1 and c2 = 2
      2  /
    
    1 row updated.
    
    SQL> update t11 set c3 = sysdate  where c1 = 2
      2  /
    
    1 row updated.
    
    SQL> select * from t11
      2  /
    
            C1         C2 C3
    ---------- ---------- ---------
             1          1 15-JUN-09
             1          2 16-JUN-09
             2          2 16-JUN-09
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  select t11.c1, func2(t11.c2) "test"
      2  from t11, (select c1, max(c3) c3 from t11 group by c1) a
      3* where t11.c1 = a.c1 and t11.c3 = a.c3
    SQL> /
    
            C1 test
    ---------- ------------------------------
             1 Accepted
             2 Accepted
    

    With greetings
    Krystian Zieja

  • The VI call does not show correct Boolean value returned from Subvi

    I have a Subvi, which returns a Boolean to indicate whether the system is WoW64 or not. When I run this by herself or with a probe VI, I get a TRUE result (my OS is 64-bit Win8, and I am running 32-bit LV2015).  When the VI is called as a Subvi, and the output is wired to a Boolean value on the front of the caller, the value is FALSE, even if it is TRUE inside the Subvi.  The LV2014 code is attached below.  It happens in 2014 but not 2013.  Is there something to do with DLL calls made by the Subvi which is corrupting the Subvi call?


  • How to display multiple values read from database in a textfield

    Hi all

    I'm working on a feature where say if there are 3 employees in a Department and then I want to show all names (separated by commas) employees of the Department in a textfield.

    do any body have any suggestions?

    Thank you
    Tauceef.

    See also:

    {: identifier of the thread = 1033907}

  • To loop through the table and use the values returned in another query

    Hello

    I tried to do something very simple, but still can not.

    I am trying to iterate on a table and use each line of a column in a where clause to display a query clause.

    For example:

    I want to retrieve all users of dba_users pass it to a clause where clause in a query to show for example account_status and profile of each user. But I want to do it in a way if I can turn the result in an html table.

    I tried too much really, so I'll post something that does not work, but which I think will show the problem I have,

    BEGIN
     FOR i IN (SELECT username from dba_users order by 1)
     LOOP
     EXECUTE IMMEDIATE 'select account_status from dba_users where username like ''||i.username||''';
     END LOOP;
     END;
     /
    

    Example of what I want to achieve:

    Suppose that there are two users, SYS, and SCOTT:

    USERNAME                       PROFILE                        ACCOUNT_STATUS
    ------------------------------ ------------------------------ --------------------------------
    SYS                            DEFAULT                        OPEN
    
    
    USERNAME                       PROFILE                        ACCOUNT_STATUS
    ------------------------------ ------------------------------ --------------------------------
    SCOTT                            DEFAULT                        OPEN
    

    Thanks in advance for your time,

    OD

    Hi Bill,

    Bill Citad kirjoitti:

    What a join or a sub query going to help me? honestly

    -- join
    select
      s.sql_id,
      h.loads_total
    from dba_hist_sqlstat h join v$sql s on (
      h.sql_id = s.sql_id
    )
    where rownum < 3
    ;
    
    -- subquery
    select
      sql_id,
      loads_total
    from dba_hist_sqlstat
    where sql_id in (
      select sql_id from v$sql where rownum < 3
    )
    ;
    
    -- correlated subquery
    select
      sql_id,
      loads_total
    from dba_hist_sqlstat
    where exists (
      select null from v$sql where sql_id = dba_hist_sqlstat.sql_id
    )
    and rownum < 3
    ;
    
    -- lateral inline view (12c)
    select
      s.sql_id,
      h.loads_total
    from dba_hist_sqlstat, lateral(
      select sql_id from v$sql where sql_id = h.sql_id
    ) s
    where rownum < 3
    ;
    
  • provide multiple values to the select query IN

    Hello

    I just wanted to know if there is a more effective way to provide values for my statement SELECT. Is what we do, gives us an excel file that contains a single column of serial numbers then we format the content so that it can be read by pl sql. By format, I mean put single quotes on the serial numbers, then separate then by comma.

    Like, we are sent

    8181818181818
    2323123525241
    1231231231234

    Then we have to get in shape to look like this (using formulas in excel)

    '8181818181818',
    '2323123525241',
    '1231231231234'

    in the process, I have to do a lot of copy and pasting that seems to take a long time.

    So, is there a way to make the process of sql pl serial passed to me as an excel file or is there any other alternative methods can I use?

    TABLE EXTERNAL research

  • Possible to contain variable multiple values?

    Is it possible the variable contains multiple values?

    In fact, I need to hold a multiple value multiple value.

    Procedure:

    Remove employee where empno in (#variable)

    Table Employees: Informix


    variable code #:

    Select relieved_employee_id in the relieved_employees (return multiple values)

    Employees table raised is in SQL SERVER


    any other approach simple approach...


    How can I approach my requriement?

    Hello

    Is it possible the variable contains multiple values?

    Usually variable ODI hold one value returned by a select query

    Procedure:

    Remove employee where empno in (#variable)

    Table Employees: Informix

    variable code #:

    Select relieved_employee_id in the relieved_employees (return multiple values)

    Employees table raised is in SQL SERVER

    any other approach simple approach...

    How can I approach my requriement?

    You can try something simiral to the following

    create an ODI procedure

    Command on the source tab:

    SQL SERVER technology
    Logic diagram should point to your schema that contains the table of relieved_employees

    query: Select relieved_employee_id you relieved_employees EMP_ID

    Target control on the tab:

    Technology: Informix
    Logic diagram should point to your schema that contains the employees table

    query: delete from employee where empno = #EMP_ID

    This will make a loop through all the values returned by your query source and delete target.

    Thank you
    Fati

  • Multiple values in the dashboard application application database Direct

    Hello

    I created a direct request from the database that accepts input from a prompt by a variable of presentation, either placed in request of db query. I realized in the process that I had to give a default input to the variable of the presentation of the petition. The input variables passed from the dashboard quick came in the right format, only if they are placed in quotation marks, Eg: "Input_Var".

    After all this, I came across a problem when multiple values are entered, the query is generated with an incorrect format. Here is the example:

    Select col1, col2

    of TabXX

    where username IN "Acct_Nm1", "Acct_Nm2"; ')}

    Is there anyway to solve this problem. Thanks in advance.

    Hi all

    I used the sequence next to convert the string separated by commas, received XML from the dash prompt.

    "Select XXX".

    movies XXX

    where the value

    in (SELECT )

    EXCERPT (VALUE (d), ' / / row/text () ") .getstringval)

    Of

    (SELECT XMLTYPE ('' |)) REPLACE ('VALUEOF (NQ_SESSION.req_var)', ';', ''). ') AS xmlval

    The DOUBLE) x,.

    ( TABLE (XMLSEQUENCE (EXTRAIT (x.xmlval, '/ lignes/ligne'))) d)"

    Create a query variable 'req_var' in the prompt to serve in "VALUEOF (NQ_SESSION.req_var)" and pass it to the report. It will be useful.

    Thank you.

  • Using the index of multiple values

    Hi guys,.

    Trying to assess the benefits of the addition of index of multiple values, a quick question on the index of multiple values:

    Here's my content from the cache:

    Key (EmpID), value [employee (age int, double salary, Department of String)]
    (1, new employee (25, 35000.0, "Admin"));
    (2, new employee (22, 30000.0, "Admin"));
    (3, new employee (34, 40000.0, 'Communications'));
    (4, new employee (36, 41000.0, "Admin"));
    (5, new employee (36, 42000.0, "HR"));
    (6, new employee (29, 30000.0, "HR"));
    (7, new employee (51, 50000.0, "BackOffice"));
    (8, new employee (36, 35000.0, "HR"));
    (9, new employee (46, 45000.0, "Admin"));
    (10, new employee (48, 47000.0, "HR"));

    If I still want to find all employees in the 'Human resources' Department and whose salary is more than 35000.

    Eventually, I would like to do the following:
    ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
    ValueExtractor depExtractor = new PofExtractor (String.class, 3);
    cache.addIndex (salExtractor, false, null);
    cache.addIndex (depExtractor, false, null);

    EqualsFilter departmentFilter = new EqualsFilter (depExtractor, 'HR');
    GreaterFilter salFilter = new GreaterFilter (salExtractor, 35000);
    Filter allFilter = new AllFilter (new filter [] {departmentFilter, salFilter});
    Employees value = cache.entrySet (allFilter));

    For my usecase above how can I use the indexing of multiple values to the same query?
    ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
    ValueExtractor depExtractor = new PofExtractor (String.class, 3);
    MultiExtractor mExtractor is new MultiExtractor (new ValueExtractor [] {salExtractor, depExtractor});.
    cache.addIndex (mExtractor, false, null);

    But how can I use the extractor to create multivalued filter queries for employees in the Department of human resources with greater than 35000 salary? Any ideas are much appreciated.


    Thank you

    D wrote:
    Hi guys,.

    Trying to assess the benefits of the addition of index of multiple values, a quick question on the index of multiple values:

    Here's my content from the cache:

    Key (EmpID), value [employee (age int, double salary, Department of String)]
    (1, new employee (25, 35000.0, "Admin"));
    (2, new employee (22, 30000.0, "Admin"));
    (3, new employee (34, 40000.0, 'Communications'));
    (4, new employee (36, 41000.0, "Admin"));
    (5, new employee (36, 42000.0, "HR"));
    (6, new employee (29, 30000.0, "HR"));
    (7, new employee (51, 50000.0, "BackOffice"));
    (8, new employee (36, 35000.0, "HR"));
    (9, new employee (46, 45000.0, "Admin"));
    (10, new employee (48, 47000.0, "HR"));

    If I still want to find all employees in the 'Human resources' Department and whose salary is more than 35000.

    Eventually, I would like to do the following:
    ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
    ValueExtractor depExtractor = new PofExtractor (String.class, 3);
    cache.addIndex (salExtractor, false, null);
    cache.addIndex (depExtractor, false, null);

    EqualsFilter departmentFilter = new EqualsFilter (depExtractor, 'HR');
    GreaterFilter salFilter = new GreaterFilter (salExtractor, 35000);
    Filter allFilter = new AllFilter (new filter [] {departmentFilter, salFilter});
    Employees value = cache.entrySet (allFilter));

    For my usecase above how can I use the indexing of multiple values to the same query?
    ValueExtractor salExtractor = new PofExtractor (Integer.class, 2);
    ValueExtractor depExtractor = new PofExtractor (String.class, 3);
    MultiExtractor mExtractor is new MultiExtractor (new ValueExtractor [] {salExtractor, depExtractor});.
    cache.addIndex (mExtractor, false, null);

    But how can I use the extractor to create multivalued filter queries for employees in the Department of human resources with greater than 35000 salary? Any ideas are much appreciated.

    Thank you

    I remember, values multiple index refers to a different concept: a multivalued index means that you can retrieve a collection of values of similar role of an attribute on which you can do Contains, ContainsAll filtering, and ContainsAny.

    In this case to fully the lever consistency of querying capabilities, you would
    - either add a sorted index with a custom comparator that compares the tables containing a salary and a Department on a first salary so the base of the Department and add a filter custom which is able to take advantage of the index for the request for the salary and also able to filter on the element of the array of index service
    -Add two independent indices (a sorted index of wages and a unsorted for the Department), in which case you can leverage all existing (GreaterThanFilter, EqualsFilter and AndFilter) code

    Best regards

    Robert

  • Return multiple values from a table

    Hi there I'm working on a bit of sql that returns values when they exist in a table.
    The code I have returns the correct value when there is an entry in the tbl_studentmodules table, as soon as there is more than one entry in this table it does display no line at all: (.)

    Can someone tell how to return multiple values?

                 select modulename from tbl_modulefeedback
    where 1 = (select count(*) from tbl_studentmodules
           where upper(:APP_USER) = upper(student_id))
    and 1 = (select count(*) from tbl_modulefeedback, tbl_studentmodules
          where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)
    Thanks in advance!

    Ashleigh

    Try this:

    select modulename
    from tbl_modulefeedback
    where 1 <= (select count(*) from tbl_studentmodules
           where upper(:APP_USER) = upper(student_id))
    and 1 <= (select count(*) from tbl_modulefeedback, tbl_studentmodules
          where tbl_modulefeedback.modulecode = tbl_studentmodules.modulecode)
    

    When you ask questions, please enter CREATE TABLE and INSERT some commands to make it easier to help you.

  • Return multiple values from a function in a SELECT statement

    I hope I've provided enough information here. If not, let me know what I'm missing.

    I create a view that will combine the information from several tables. Most are pretty simple, but there are a couple of columns in the view that I need to get by running a function within a package. Even if this is quite simple (I have a function named action_date in a package called rp, for example, that I can use to return the date that I need through SOME rp.action_date (sequence_number).

    Here is the question: I really need to return several bits of information of the same record (not only action_date, but also action_office, action_value, etc.)-a join of the tables will work not here, as I will explain below. I can, of course, perform a function separate for each statement, but this is obviously inefficient. Within the select statement of the view, however, I don't know how each of the values that I need to get back.

    For example, right now, I have:

    Table 1:
    sequence_number NUMBER (10),
    name varchar (30),
    ...

    Table2:
    Table1_seq NUMBER (10),
    action_seq NUMBER (10),
    action_date DATE,
    action_office VARCHAR (3),
    action_value VARCHAR (60),
    ...

    I can't just simply join Table1 and Table2 because I have to perform processing in order to determine the rows returned matching, I really need to select. If the package opens a cursor and treats each line until it finds the one I need.

    The following works but is ineffective since all calls to the package returns the columns of the same record. I don't know how to put all the values that I need in the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    RP.action_date (sequence_number) action_date,
    RP.action_office (sequence_number) action_office,
    RP.action_value (sequence_number) action_value
    FROM table1

    Is there a way to return multiple values in my SELECT statement or I'm going about this all wrong?

    Any suggestions?

    Thank you very much!

    Hello

    What you want is a Query of Top - N , what you can do using the ROW_NUMBER analytic function in a subquery, like this:

    WITH     got_rnum     AS
    (
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    )
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    

    As written, this returns a single line (at most).
    I suspect you'll actually get a rank for each group , where a group is defined by a value in a table in which you join.
    In this case, add a PARTITION BY clause to the ROW_NUMBER function.
    If post you a small example of data (CREATE TABLE and INSERT statements), I could show you exactly how.
    As I don't have your tables, I'll show you the use of the tables in the scott schema.
    This is a view containing data in the scott.dept table and also to scott.emp, but only for the highest employee in each Department (in other words, the employee whose oldest hire date). If there be a tie for the first hire date, while the candidate with the lowest empno is selected.

    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
    (
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    )
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    ;
    
    SELECT     *
    FROM     senior_emp
    ;
    

    Output:

    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
    ---------- -------------- ---------- ---------- ---------
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81
    

    Moreover, one of the conditions to the query you posted has been

    action_office     LIKE 'E'
    

    which equals

    action_office     = 'E'
    

    (AS is always equivalent to = if the string that follows AS does not contain the winning cards.)
    Did you mean say that or did you mean something like this:

    action_office     LIKE 'E%'
    

    Instead?

  • Another REGEXP question: how to extract multiple values from a string

    Hi, how can I retrieve multiple values to a string with RegExp with Oracle SQL constructs?

    Have looked at the various examples, I cannot understand this.
    the following Sql code
    select
       regexp_substr(sessie."rollen", 'CN=A_role') "A_role"
       from ( 
    select '
    CN=A_role,OU=a_org_unit,OU=another_org_unit,DC=bz,DC=ad,DC=min,DC=local
    CN=Another_role,OU=some_org_unit,DC=bz,DC=ad,DC=min,DC=local
    CN=Users,OU=Dep,DC=bz,DC=ad,DC=min,DC=local
    '   "rollen" from dual
    ) sessie;
    Returns CN = A_role.
    I want him back all of the CN = concatenated values with a semicolon and stripped of the CN = bit.
    So: A_role; Another_role; Users .

    Any help would be much appreciated. Here I use database 11g 11.2.0.2.0.

    Does anyone have an idea how to do this in SQL?

    best regards Mike

    Hello
    If using Oracle 11 g

    with tst
      as (select   'CN=A_role,OU=a_org_unit,OU=another_org_unit,DC=bz,DC=ad,DC=min,DC=local,'
                 ||'CN=Another_role,OU=some_org_unit,DC=bz,DC=ad,DC=min,DC=local,'
                 ||'CN=Users,OU=Dep,DC=bz,DC=ad,DC=min,DC=local' as rollen
            from dual
          )
    select listagg(sub, ',') within group (order by rn) as res
      from (select regexp_substr(rollen, '(CN=)([[:alnum:]_]+)',1,rownum,'i',2) sub, rownum rn
              from tst
           connect by level <=length(rollen)
           )
     where sub is not null       
    
  • I need to return multiple values in function

    create or replace function f (p) in varchar2) return varchar2
    is
    a number (10);
    Start

    for loop 1 in 1.10
    Select instr('yyyyyyyyynnnnnyynny','y',1,i) in the doubles.
    end loop;
    return a;
    end;

    my function return a value, but I need to return multiple values
    Thanks in advance

    I don't know if that's what you want (you should give expected results also)

    SQL> create or replace type mytabletype as table of number;
      2  /
    
    Type created.
    
    SQL> create or replace function f (p in varchar2) return myTableType pipelined is
      2    a number(10);
      3  begin
      4    for i in 1..10 loop
      5      select instr('yyyyyyyyynnnnnyynny','y',1,i) into a from dual;
      6      pipe row (a);
      7    end loop;
      8  end;
      9  /
    
    Function created.
    
    SQL> select * from table(f('1'));
    
    COLUMN_VALUE
    ------------
               1
               2
               3
               4
               5
               6
               7
               8
               9
              15
    
    10 rows selected.
    
    SQL>
    

    Published by: Leo Mannhart on March 22, 2011 11:01

    could even be compressed into

    create or replace function f (p in varchar2) return myTableType pipelined is
    begin
      for i in 1..10 loop
        pipe row (instr('yyyyyyyyynnnnnyynny','y',1,i));
      end loop;
    end;
    
  • Return multiple values at once of the listOfValues region

    Friends,

    I created a (listOfValues) region that has 4 fields/columns

    ResponsibilityName, ResponsibilityId, ApplicationName, ApplicationId

    I assigned a responsibility field ResponsibilityName of the listOfValues in a page.

    It works fine when I select a value in this LOV. It returns a value to the field of 'Responsibility' of the page.

    Is it possible to return the other 3 fields so while selecting ResponsibilityName in LOV. for example while you select a value for the field 'Responsibility', can the LOV return ResponsibilityId LOV to the 'ResponsibilityId' field in the page, at the same time?

    1 selection can return values 1 to the fields?

    You can return multiple values in the LOV. Simply create a result to the mapping of the array element Lov to the basic element of page. Once you select a value from the LOV, the element of basic page could get filled in with the value on the table of lov whereby it has been mapped.

    Concerning
    Sumit

  • What subprogramme should we prefer to return multiple values with OUT parameter?

    Hello

    I worked on the procedures and functions, and aware of their differences. Today I have an interview question that - suppose I don't have return multiple values through a subroutine and I want nor run any what DML within this subprogramme and I want to use this subprogramme in the SQL query. What subprogramme I would prefer - "Operating Mode" or "Function" and why?

    In my view, both can be used in this case, but want to see your views and opinions.

    Kind regards

    Sachin jerbi

    In terms of software engineering, if you claim something that you expect to "return" something (a value or values) then you use a function.  If you call something to "do" something, and then you use a procedure.

    THE settings are not good practices in many cases and should not strictly considered "return" of values.  Instead, they are assigned values in the code and generally act as pointers to the original variable/structure that was passed as a parameter (the actual internals of Oracle don't quite do it, but in principle this is what they do).

    A return value (or structure) of a function is basically push in the battery to the point that the RETURN statement is issued, and then the code calling the stack appears to assign it to a variable or placeholder, it should go in.

    If it seems a little difference between procedures and functions to some people, it is recommended to use functions for obtaining values and procedures to do things, in most cases.  It is not just "syntactic sugar", as mentioned above.

Maybe you are looking for

  • the sims3 game laucher does not open to play

    I played the sims3 for several months, and now the game Launcher does not open to play the game. He won't go to the black screen before the green diamonds came then go to my office. Now, it stays black. I uninstalled and reinstalled but still the sam

  • Toggle the Partitions - disk management

    I have to dual boot with Windows 7 Ultimate 64 bit on the partition C: and the Windows Technical Preview on the D: partition.  For some reason, the D: partition appears now as 'Active' instead of the C: partition. I want to C: partition 'Active'. As

  • Does anyone else have incorrect time zones?

    The time zones on my Surface are incorrect. Although I am in Central time, I need to put it at the time of the Pacific in order to have the exact time. It's just a bug/all the world knows this?

  • Install the fake OS detection

    I recently bought Lr6 from Best Buy. When I come back I install it, it says that it s Doi is not supported in Windows Vista. I don't have Windows Vista, I have Windows 7. Help, please!

  • Adapter of storage latency Metrics

    HelloI notice some read latency in most of my guests showing a maximum of 19 ms, as high as 31 ms, the runtime currently around 3-7 ms.  Is this acceptable?  For some reason, I feel like they are normally less than that.