XML QUERY HELP NEEDED

Hello

Need help with writing a query.
SQL> SELECT xmlelement("P",xmlforest(P.process_id AS Ppid),
  2   xmlagg(xmlelement("PI",XMLFOREST( PI.question_id AS PIqid,
  3   PI.process_id AS PIpid,
  4   PI.innertext AS PItext),
  5   xmlagg(Xmlelement("PO",xmlforest( PO.option_id AS POoid,
  6   PO.question_id AS POqid,
  7   PO.process_id AS popid
  8   ))
  9  ORDER BY PO.option_id))
 10     ORDER BY PI.question_id ) )
 11     FROM liveProcess_ec P
 12  INNER JOIN vw_liveProcessItem_Sim_v6 PI
 13       ON P.process_id = PI.process_id
 14  LEFT OUTER JOIN vw_liveProcessOption_Sim_v6 PO
 15       ON PI.question_id = PO.question_id
 16  AND PI.process_id      = PO.process_id
 17    WHERE p.process_id   =450
 18  GROUP BY p.process_id,PI.question_id,PI.process_id,PI.innertext
 19    ORDER BY p.process_id;
SELECT xmlelement("P",xmlforest(P.process_id AS Ppid),
                                *
ERROR at line 1:
ORA-00937: not a single-group group function
Thanks in advance

I think you are looking for something like this:

SQL> SELECT
  2      XMLAgg(
  3        XMLElement("P"
  4          ,XMLElement("Ppid",p.process_id)
  5          ,XMLElement("qcount",100)
  6       ,(SELECT
  7           XMLAgg(
  8             XMLELement("PI"
  9               , XMLElement("PIqid", pi.question_id)
 10               , XMLElement("PIpid", pi.process_id)
 11               , XMLElement("PItext", pi.innertext)
 12               , XMLAgg(
 13               XMLElement("PO"
 14                    ,XMLForest(
 15                     po.option_id "POoid"
 16                   , po.question_id "POqid"
 17                   , po.process_id "POpid"
 18                 ) AS "PO"
 19                     )
 20            ) --xmlagg
 21             ) --PI
 22           ) --xmlagg
 23           FROM
 24           VW_LIVEPROCESSITEM_SIM_v6 pi
 25            , VW_LIVEPROCESSOPTION_SIM_v6 po
 26           WHERE p.process_id=pi.process_id
 27             AND pi.question_id=po.question_id(+)
 28        GROUP BY pi.question_id,pi.process_id,pi.innertext
 29        )--select ended
 30        )
 31      ) xm
 32  FROM
 33    liveprocess_ec p
 34  GROUP BY p.process_id
 35  ORDER BY p.process_id;

output

450 100 1 450 CBB1015 - Router Firewall Settinngs Process 2 450 Is the customers PC Firewall turned off? 1 2 450 2 2 450 3 450 Advise the customer to turn off the PC Firewall in order to continue. Has this been done? 1 3 450 2 3 450 ... ... ... 16 450 Issue Resolved

Tags: Database

Similar Questions

  • SQL query help needed in the Clause type

    Hello

    I'm currently learning Clause type. How can I write in the clause type to get the result below:

    I have a table like this

    DEPTNO ENAME

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

    20 SMITH

    CELINE 10

    BOND 20

    ALLEN 30

    WARD 30

    20 JONES

    30 MARTIN

    30 BLAKE

    10 CLARK

    SCOTT 20

    10 KING

    30 TURNER

    20 ADAMS

    30 JAMES

    20 FORD

    10 MILLER

    I want the output should look like this

    DEPTNO ENAME

    ------     -----

    CELINE 10, CLARK, KING, MILLER

    20 JONES, ADAMS, BOND, FORD, SCOTT, SMITH

    30 MARTIN, JAMES BLAKE, WARD, TURNER, ALLEN

    Hear is the script I am currently working on.

    with emp_group as

    (

    Select 20 deptno, ename 'SMITH' Union double all the

    choose 10, 'CÉLINE' from dual union all

    Select 20, "BOND" of all the double union

    Select 30, 'ALLEN' from dual union all

    Select 30, 'WARD' of all the double union

    Select 20, "JONES' from dual union all

    Select 30, 'MARTIN' from dual union all

    Select 30, "BLAKE" from dual union all

    choose 10, 'CLARK' from dual union all

    Select 20, 'SCOTT' from dual union all

    choose 10, 'KING' of the dual union all

    Select 30, 'TURNER' from dual union all

    Select 20, 'ADAMS' from dual union all

    Select 30, 'JAMES' of the dual union all

    Select 20, 'FORD' Union double all the

    choose 10, 'MILLER' from dual

    )

    Select

    DEPTNO

    A1

    of emp_group

    model

    ignore the nav

    partition (deptno)

    dimension (ROW_NUMBER() over (PARTITION BY deptno ORDER BY ename DESC) rn)

    measures (ename, LPAD(' ', 100) A1)

    rules)

    A1 [rn > 0] = ename [cv ()],

    A1 [0] = ename [cv ()]

    )

    order by deptno

    ;

    your help is very appreciated.

    Thank you in advance.

    Try this.

    Select

    *

    Of

    (

    with emp_group as

    (

    Select 20 deptno, ename 'SMITH' Union double all the

    choose 10, 'CÉLINE' from dual union all

    Select 20, "BOND" of all the double union

    Select 30, 'ALLEN' from dual union all

    Select 30, 'WARD' of all the double union

    Select 20, "JONES' from dual union all

    Select 30, 'MARTIN' from dual union all

    Select 30, "BLAKE" from dual union all

    choose 10, 'CLARK' from dual union all

    Select 20, 'SCOTT' from dual union all

    choose 10, 'KING' of the dual union all

    Select 30, 'TURNER' from dual union all

    Select 20, 'ADAMS' from dual union all

    Select 30, 'JAMES' of the dual union all

    Select 20, 'FORD' Union double all the

    choose 10, 'MILLER' from dual

    )

    Select

    DEPTNO

    names

    rn

    of emp_group

    model

    ignore the nav

    partition (deptno)

    dimension of)

    ROW_NUMBER() over (PARTITION BY deptno ORDER BY ename) rn

    )

    measures (ename, cast (null as names of varchar2 (40)))

    rules

    (

    names [any] order by desc = ename [cv ()] rn | «, » || names [cv () + 1]

    )

    order by deptno

    )

    where rn = 1

    Best regards, Andrei

  • Hierarchical Oracle query help needed - path between the crux of two brothers and sisters

    I want to find the path between two nodes of oracle hierarchical Table.

    Consider the following case-
    NodeId - ParentId
    =============
    1 > > > > > > 0
    2 > > > > > > 1
    3 > > > > > > 2
    4 > > > > > > 3
    5 > > > > > > 0
    6 > > > > > > 5
    Here I want to query the database table that if there is a path between nodes 3 and 5?
    The previous query you provided work upwards to the root node.

    Here is my expected result, 3-> 2-> 1-> 0-> 5

    Yet once if I have a query in the table to get the path between 1 and 3, I want to get out of the way - next
    1-> 2-> 3

    Therefore, the query works in both cases. Where ADI root can act as an intermediate or no node.

    Can you please guide me how I can get it?

    Thank you.

    Hello

    user13276471 wrote:
    I want to find the path between two nodes of oracle hierarchical Table.

    Consider the following case-
    NodeId - ParentId
    =============
    1 >>>>>> 0
    2 >>>>>> 1
    3 >>>>>> 2
    4 >>>>>> 3
    5 >>>>>> 0
    6 >>>>>> 5
    Here I want to query the database table that if there is a path between nodes 3 and 5?
    The previous query

    What application is this? If you're referering to another thread, then post a link, such as {message identifier: = 10769125}

    you provided work upwards to the root node.

    Here is my expected result, 3--> 2--> 1--> 0--> 5

    Yet once if I have a query in the table to get the path between 1 and 3, I want to get out of the way - next
    1--> 2--> 3

    Therefore, the query works in both cases. Where ADI root can act as an intermediate or no node.

    Can you please guide me how I can get it?

    I think you want something like this:

    WITH     bottom_up_from_src    AS
    (
         SELECT     nodeid
         ,     parentid
         FROM     table_x
         START WITH     nodeid      = :src_nodeid
         CONNECT BY     nodeid   = PRIOR parentid
    )
    ,     bottom_up_from_dst     AS
    (
         SELECT     *
         FROM     bottom_up_from_src
        UNION ALL
         SELECT     parentid     AS nodeid
         ,     nodeid          AS parentid
         FROM     table_x
         WHERE     nodeid     NOT IN (
                                          SELECT  nodeid
                                   FROM    bottom_up_from_src
                                      )
         START WITH     nodeid        = :dst_nodeid
         CONNECT BY     nodeid        = PRIOR parentid
    )
    SELECT      :src_nodeid || SYS_CONNECT_BY_PATH (parentid, '-->')     AS display_path
    FROM       bottom_up_from_dst
    WHERE       parentid     = :dst_nodeid
    START WITH  nodeid     = :src_nodeid
    CONNECT BY  nodeid     = PRIOR parentid
    ;
    

    This will show how you can get it from: src_nodeid at dst_nodeid, moving to the top or to the bottom of a hierarchy at a time step. This will work regardless of the fact that


    • : src_nodeid is the ancestor of the: dst_nodeid, or
    • : src_nodeid is a descendant of: dst_nodeid, or
    • both: src_nodeid and: dst_nodeid are the descendants of another node (e.g. 0).

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0). It is always important, but particularly so with CONNECT BY queries, because each version since Oracle 7 had significant improvements in this area.
    See the FAQ forum {message identifier: = 9360002}

  • Hierarchical query help need to Oracle

    Hello
    I'm in a deep trouble.

    I want to do a hierarchical query in my TreeView table in oracle. But I want that the query retrieves information path between two nodes.

    Review the table below.

    ------------------------------------------------------
    Node ID | Name of the node. ID of the parent
    -----------------------------------------------------
    1A 0
    2 1
    3C0
    4 2
    -----------------------------------------------------

    What I want is that I'll give you 2 node id in the request. One is the source node and the other is the destination node.
    so if I put 1 node and node 4, I want to be the output

    1-> 2-> 4

    I want just a return line. Or there may be several rows but stands only the node of this path.

    1
    2
    4
    ----

    This means that I don't want to node 3 in the search result.


    More if I have the source as 4 node and the node of destination as 1 then I will also get an output of the query as below-
    4-> 2-> 1

    This means that the search for the query for the result in a way directional bi.


    If anyone can give me some information about who it's going to be great for me.

    Published by: user13276471 on December 31, 2012 03:21

    Hello

    Welcome to the forum!

    Assuming you have 2 separate nodes: Node_A and: node_b, you can find the hierarchy from one to the other like this:

    SELECT     SYS_CONNECT_BY_PATH (node_id, ',')     AS lineage
    FROM     table_x
    WHERE     node_id     IN (:node_a, :node_b)
    AND     LEVEL     > 1
    START WITH     node_id          IN (:node_a, :node_b)
    CONNECT BY     parent_id     = PRIOR node_id
    ;
    

    It will work if: the Node_A is an ancestor of the: node_b, or if: node_b is an ancestor of the: Node_A.
    If is the ancestor of the other, then it will produce 0 rows.

  • OAG - insert timestamps in XML query

    Hello

    I need to insert timestamps in XML query. Please suggest steps/options/filters to do?

    for example

    XML request:

    < xml >

    < timestamp > < / timestamp >

    < / xml >

    output must be

    < xml >

    < timestamp > 2006 - 05 - 04T 18: 13:51.0Z < / timestamp >

    < / xml >

    Kind regards

    Ganesh

    Hello

    You want to use the filter to add an XML node.

    Create a JavaScript filter, first to do something like this:

    function invoke (msg)

    {

    now = new Date();

    Msg.put (elements "UTCTime", now.toUTCString ());

    Returns true;

    }

    In Add an XML node to the node content add:

    ${UTCTime elements}

  • Problem of XML query structure

    Hi experts,
    I am looking for help on the following XML query. I have a table (for example) organized as such:
    meas     data_element     
    ------- ------------------- 
    ABC     rate                   
    DEF     rate1                    
    DEF     rate2                    
    DEF     rate3                    
    GHI     rate                    
    JKL     rate1a            
    JKL     rate2b             
    I try to keep the column 'soul' as the attribute of the top-level node, with the "data_elements" as attributes of the children of the 'SOUL '.

    In short, I am looking for the following output, but well... keep coming up short.
    <meas id="ABC"> 
         <data_elements>
            <data_element id="rate">
                <rpt>false</rpt> 
             </data_element>
        </data_elements>
    </meas>
    <meas id="DEF">
         <data_elements>
              <data_element id="rate1">
                   <rpt>false</rpt>
              </data_element>
                     <data_element id="rate2">
                   <rpt>false</rpt> 
              </data_element>
              <data_element id="rate3">
                      <rpt>false</rpt> 
              </data_element>
         <data_elements>
    </meas>
    .....and so forth...
    I'm unable to get multiple lines of "data_element" under "data_elements" and the single "meas" a single node, any suggestions? My code keeps generating several lines. The crux of the rpt is a constant value of 'false '.
    Thank you

    You group and aggregate using XMLAgg:

    SQL> set long 5000
    SQL>
    SQL> with sample_data (meas, data_element) as (
      2    select 'ABC',     'rate'   from dual union all
      3    select 'DEF',     'rate1'      from dual union all
      4    select 'DEF',     'rate2'  from dual union all
      5    select 'DEF',     'rate3'  from dual union all
      6    select 'GHI',     'rate'   from dual union all
      7    select 'JKL',     'rate1a' from dual union all
      8    select 'JKL',     'rate2b' from dual
      9  )
     10  select xmlserialize(content
     11           xmlagg(
     12             xmlelement("meas",
     13               xmlattributes(meas as "id")
     14             , xmlelement("data_elements",
     15                 xmlagg(
     16                   xmlelement("data_element",
     17                     xmlattributes(data_element as "id")
     18                   , xmlelement("rpt", 'false')
     19                   )
     20                   order by data_element -- if necessary
     21                 )
     22               )
     23             )
     24           )
     25           indent
     26         ) as result
     27  from sample_data
     28  group by meas ;
    
    RESULT
    --------------------------------------------------------------------------------
    
      
        
          false
        
      
    
    
      
        
          false
        
        
          false
        
        
          false
        
      
    
    
      
        
          false
        
      
    
    
      
        
          false
        
        
          false
        
      
    
     
    
  • Please can someone help, need password CNU9497P2C

    I have the same problem and its driving me crazy... I need the BIOS password because I can't access to this

    [number of Series edited by Moderator]

    Please can someone help, need password

    HP MINI CQ10

    Sweb try.

    e9lovox27e

    3rd letter tiny L.

    4th and 6th letter lowercase o.

    Use this code to go into the BIOS.

    Disable all passwords that are enabled.

    If demand for CURRENT password using this code.

    Request NEW password just press ENTER.

    If asked to hit just to CHECK password to enter.

    Save and exit.

    REO

    I must inform you that these services are not endorsed by HP, and that HP is not responsible for any damages that may occur to your system using these services. Please be aware that you do so at your own risk.

  • Recovery of OSB road Note Error Handler xml query

    Hi guys,.

    I don't know if there is a thread that has already been addressed, but I couldn't find anything.

    Here's the scenario. I created Proxy Service X (http transport protocol) that routes a message to Business Service Y. Business Service Y called myWebService that is deployed in a remote domain. I have intentionally to cancel the deployment of the EAR that contains myWebService in the remote domain. When the Business Service Y try to call myWebService she will appear in error, the following message:
    < con xmlns:con: fault = "http://www.bea.com/wli/sb/context" >
    < con: errorCode > BEA-380002 < / con: errorCode >
    < con: reason > not found < / con: reason >
    < con: location >
    < con: node > RouteNode1 < / con: node >
    pipeline response - < con: path > < / con: path >
    < / con: location >
    < / con: fault >

    Business Service Z is an independent service that is used to send messages to a queue. I have an route Error Handler node Proxy Service X using a legend Service to route messages to Business Service Z.

    Now in the Proxy Service X error of node Road Manager , I would like to recover the original xml query that was received by Proxy Service X and send it to a queue by making use of the previously mentioned Legend of Service that routes messages to Business Service Z whenever the BEA-380002 of error type occurs.

    When you look at the response of the legend of Service (by making use of reports), the item entering the http transport layer does not contain the xml request, but simply the metadata of the message. How can I get the original xml to the scenario above query?

    Kind regards
    Ophola...

    Add an action to assign the title of the action request routing Actions. Using yield action assign the $body (initial application of XML) in a var, for example bodyvar. Now in the route node error handler, you can get the original query in the variable $bodyvar

    Kind regards
    Anuj

  • need help on xml query.

    pls click here for an example of xml data
    http://pcls1.craftyclicks.co.UK/XML/RapidAddress?postcode=AA11AA
    I make the following query to retrieve the values of xml data
    Select x1.org, x1.org2, x1.org3, x1.org4, x1.org5 in the xml_data_tab x, xmltable ('/ CraftyResponse/address_data_paf_compact/path/delivery_point ' in passing x.xml_data)
    columns
    org varchar2 (500) 'organisation_name' path, org2 and varchar2 (500) 'building_number', org3 varchar2 (500) "building_name" path
    path of varchar2 (500) of the org4 "dependent_locality", org5 varchar2 (500) way 'city') x 1;
    This is the output...

    org4 and org5 is foul can guide me what I do in the script...

    SQL > /.

    ORG AND ORG2 TO ORG3 ORG4 ORG5
    ---------- -------------------- -------------------- -------------------- ----------
    THE BAKERY 1
    MOVIES R US 3
    FAMILY BUT 7
    DEAR

    BIG HOUSE
    17 LITTLE COTTAGE

    SQL > spool off









    Here is an example of xml code
    < CraftyResponse >
    < address_data_paf_compact >
    < thoroughfare_count > 1 < / thoroughfare_count >
    < artery >
    < delivery_point_count > 5 < / delivery_point_count >
    < delivery_point >
    < organisation_name > THE BAKERY < / organisation_name >
    < department_name / >
    < po_box_number / >
    < building_number > 1 < / building_number >
    < sub_building_name / >
    < building_name / >
    < udprn > 12345678 < / udprn >
    < / delivery_point >
    < delivery_point >
    < organisation_name > MOVIES R US < / organisation_name >
    < department_name / >
    < po_box_number / >
    < building_number > 3 < / building_number >
    < sub_building_name / >
    < building_name / >
    < udprn > 12345679 < / udprn >
    < / delivery_point >
    < delivery_point >
    < organisation_name > FAMILY BUTCHER < / organisation_name >
    < department_name / >
    < po_box_number / >
    < building_number > 7 < / building_number >
    < sub_building_name / >
    < building_name / >
    < udprn > 12345680 < / udprn >
    < / delivery_point >
    < delivery_point >
    < organisation_name / >
    < department_name / >
    < po_box_number / >
    < building_number / >
    < sub_building_name / >
    < building_name > BIG HOUSE < / building_name >
    < udprn > 12345681 < / udprn >
    < / delivery_point >
    < delivery_point >
    < organisation_name / >
    < department_name / >
    < po_box_number / >
    < building_number > 17 < / building_number >
    < sub_building_name / >
    < building_name > LITTLE COTTAGE < / building_name >
    < udprn > 12345682 < / udprn >
    < / delivery_point >
    < dependent_thoroughfare_name / >
    < dependent_thoroughfare_descriptor / >
    < thoroughfare_name > TOP < / thoroughfare_name >
    < thoroughfare_descriptor > STREET < / thoroughfare_descriptor >
    < / artery >
    < double_dependent_locality / >
    < dependent_locality > CRAFTY VALLEY < / dependent_locality >
    < City > BIG CITY < / City >
    < postal_county > COUNTY POSTAL < / postal_county >
    < traditional_county > COUNTY TRADITIONAL < / traditional_county >
    < ZipCode > AA1 1AA < / code >
    < / address_data_paf_compact >
    < / CraftyResponse >

    for example

    SQL> select x2.org
      2       , x2.org2
      3       , x2.org3
      4       , x1.org4
      5       , x1.org5
      6  from xmltable('/CraftyResponse/address_data_paf_compact'
      7         passing httpuritype('http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode=AA11AA').getxml()
      8         columns org4 varchar2(20) path 'dependent_locality'
      9               , org5 varchar2(20) path 'town'
     10               , delivery_points xmltype path 'thoroughfare/delivery_point'
     11       ) x1
     12     , xmltable('/delivery_point'
     13         passing x1.delivery_points
     14         columns org  varchar2(20) path 'organisation_name'
     15               , org2 varchar2(20) path 'building_number'
     16               , org3 varchar2(20) path 'building_name'
     17       ) x2
     18  ;
    
    ORG                  ORG2                 ORG3                 ORG4                 ORG5
    -------------------- -------------------- -------------------- -------------------- --------------------
    THE BAKERY           1                                         CRAFTY VALLEY        BIG CITY
    FILMS R US           3                                         CRAFTY VALLEY        BIG CITY
    FAMILY BUTCHER       7                                         CRAFTY VALLEY        BIG CITY
                                              BIG HOUSE            CRAFTY VALLEY        BIG CITY
                         17                   LITTLE COTTAGE       CRAFTY VALLEY        BIG CITY
     
    
  • Query that needed help

    Hello
    I need help to form a query. I have two tables Support_issues and Support_comments with the information below.
    I want to create a query to view the account of the situation for the last 15 days until today.
    Sample Input data
    
    support_issues: 
    ISSUE_ID  ISSUE_DESC  CREATION_DATE  STATUS
    1          AAA        01/NOV/2011    Open
    2          BBB        02/NOV/2011    Closed
    3          CCC        02/NOV/2011    Open
    4          DDD        03/NOV/2011    Reopened
    5          EEE        03/NOV/2011    Reopened
    
    support_comments:
    COMMENT_ID  ISSUE_ID  COMMENT_DESC  STATUS  UPDATE_TIME
    101          1        aaa           Open    01/NOV/2011
    102          2        bbb           Open    02/NOV/2011
    103          2        bbbbbb        Closed  03/NOV/2011
    104          2        bbbb11        Reopened 03/NOV/2011
    105          3        ccc           Open     02/NOV/2011
    106          2        bbbbb         Closed   03/NOV/2011
    107          4        ddddd         Open     03/Nov/2011
    108          5        eeeee         Open     03/NOV/2011
    109          4        343434        Closed   06/NOV/2011
    110          4        dfdf          Reopened 07/NOV/2011
    111          5        dfdfdf        Closed   08/NOV/2011
    112          5        udehjk        Reopened 10/NOV/2011
    Sample output:
    
    DATE         Created   Reopened   Closed
    28/OCT/2011  0         0          0
    29/OCT/2011  0         0          0
    30/OCT/2011  0         0          0
    31/OCT/2011  0         0          0
    01/NOV/2011  1         0          0
    02/NOV/2011  2         0          0
    03/NOV/2011  2         1          2
    04/NOV/2011  0         0          0
    05/NOV/2011  0         0          0
    06/NOV/2011  0         0          1
    07/NOV/2011  0         1          0
    08/NOV/2011  0         0          1
    09/NOV/2011  0         0          0
    10/NOV/2011  0         1          0
    11/NOV/2011  0         0          0
    For "Created" count of status must be taken Support_issues table, for others it must be taken from table Support_comments.

    Please help me to form a query for this!

    Thank you
    Mukesh

    Hello

    Try the following query

    with t1 as
    (
    select to_char(sysdate-level+1,'dd-mm-yyyy') as date_range from dual where level<16 connect by sysdate-16
    

    Cannot test because I did not create, insert commands...

  • Help needed dynamic query

    Hai I want dynamic query for framing
    CREATE TABLE PI4 (COR varchar2(1),dep varchar2(3),cod_rc varchar2(2))
    
    insert into pi4(dep,cod_rc) values('A01','5C')
    
    insert into pi4(dep,cod_rc) values('DAC','5L')
    HORN must be updated using dynamic query
    as below
    UPDATE PI4         
            SET
         PI4.COR = ’O’
    WHERE
         PI4.DEP IN ('A01','A02','A03')
    OR
         (
         PI4. dep IN ('DAC','FTS','G12')
         AND
         PI4.COD_RC = '5L'
         )
    sql_stament is that the variable must be set to above code.

    Pls help


    S

    Check below the code where the CO value is assigned dynamically to a p_cor variable

    DECLARE
    v_sql_statement VARCHAR2(32767) := NULL;
    p_cor VARCHAR2(10) := 'O';
    BEGIN
    v_sql_statement := 'UPDATE PI4 SET PI4.COR ='||p_cor||' WHERE (PI4.DEP IN (''A01'',''A02'',''A03'') OR (PI4. dep IN (''DAC'',''FTS'',''G12'') AND PI4.COD_RC = ''5L''))';
    EXECUTE IMMEDIATE v_sql_statement;
    END;
    

    If you do not need dynamic query to perform the update:

    See the code below:

    DECLARE
    p_cor VARCHAR2(10) := 'O';
    BEGIN
    UPDATE PI4 SET PI4.COR =p_cor WHERE PI4.DEP IN ('A01','A02','A03') OR (PI4. dep IN ('DAC','FTS','G12') AND PI4.COD_RC = '5L'));
    END;
    

    Published by: AP on July 27, 2010 03:39

    Published by: AP on July 27, 2010 04:51: end tag code included

  • Help needed to display a column in a query for report

    Hello

    I need your help for the display of the total quantity based on a column that is already read by the query. My query is below:


    SELECT 'Order MO' we.wip_entity_name, msi.segment1 'MO Assembly. "
    MSI.item_type ITU, we.primary_item_id,
    TRUNC (wdj.scheduled_start_date) "regular MO Start Date."
    WDJ.start_quantity 'MO planned Qty. "
    WDJ.quantity_completed 'MO finished Qty. "
    (wdj.start_quantity - wdj.quantity_completed) "MO remaining Qty."
    (CASE
    WHEN (SUBSTR (wdj.attribute7, 3) = mtrl.line_id)
    AND we.primary_item_id <>mtrl.inventory_item_id
    )
    THEN we1.wip_entity_name
    Of OTHER mtrh.request_number
    END
    ) mo_number,.
    (CASE
    WHEN (SUBSTR (wdj.attribute7, 3) = mtrl.line_id)
    AND we.primary_item_id <>mtrl.inventory_item_id
    )
    THEN msi2.segment1
    END
    ) mo_assembly,.
    (CASE
    WHEN we.primary_item_id <>mtrl.inventory_item_id
    THEN TRUNC (wdj.scheduled_start_date)
    Of OTHER TRUNC (mtrl.date_required)
    END
    ) scheduled_start_date,.
    Mtrl.Quantity required_quantity,
    NVL (mtrl.quantity_delivered,
    NVL (mtrl.quantity_detailed, 0)
    ) issued_qty,.
    Mtrl.line_id, msi.inventory_item_id, mtrl.header_id,
    remaining_qty einv_mo_reserve_remain_qty (mtrl.line_id),
    einv_get_real_onhand_qty (mtrl.organization_id,
    Mtrl.inventory_item_id,
    Mtrl.from_subinventory_code,
    Mtrl.from_locator_id
    ) onhand.
    DECODE (a.remain_qty,
    0, (wdj.start_quantity - wdj.quantity_completed).
    a.remain_qty
    ) mo_assy_remain_qty
    OF wip_entities.
    wip_entities we1,
    wdj wip_discrete_jobs,
    wip_discrete_jobs wdj1,
    MSI mtl_system_items_b,
    wip_lines wl,
    mil mtl_item_locations
    mtl_txn_request_lines mtrl,
    mtl_txn_request_headers mtrh,
    mfg_lookups ml,
    mfg_lookups ml1,
    mtl_system_items_b msi2,
    wip_operation_resources wor,
    (SELECT NVL (SUM (wdj.required_quantity - wdj.quantity_issued),))
    0
    ) remain_qty,.
    inventory_item_id
    OF wip_requirement_operations wdj
    WHERE wdj.organization_id = 205
    GROUP BY inventory_item_id) a
    WHERE we.organization_id = wdj.organization_id
    AND we.wip_entity_id = wdj.wip_entity_id
    AND wdj.organization_id = msi.organization_id
    AND wdj.primary_item_id = msi.inventory_item_id
    AND wdj.organization_id = mtrl.organization_id
    AND wdj.organization_id = mil.organization_id
    AND wdj.completion_subinventory = mil.subinventory_code
    AND wdj.completion_locator_id = mil.inventory_location_id
    AND SUBSTR (wdj.attribute7, 3) = mtrl.line_id
    AND wdj.organization_id = wl.organization_id
    AND wdj.line_id = wl.line_id
    AND wdj.organization_id = wor.organization_id
    AND wdj.wip_entity_id = wor.wip_entity_id
    AND wor.autocharge_type = ml.lookup_code
    AND ml.lookup_type = 'BOM_AUTOCHARGE_TYPE. '
    AND mtrh.header_id = mtrl.header_id
    AND mtrl.inventory_item_id = msi2.inventory_item_id
    AND msi2.organization_id = wdj.organization_id
    AND ml1.lookup_type = 'MTL_TXN_REQUEST_STATUS. '
    AND ml1.lookup_code = mtrl.line_status
    AND wdj.start_quantity > 0
    AND wdj.start_quantity > wdj.quantity_completed
    AND a.inventory_item_id = msi.inventory_item_id
    AND mtrl.inventory_item_id = we1.primary_item_id
    AND wdj1.wip_entity_id = we1.wip_entity_id
    AND SUBSTR (wdj1.attribute7, 3) = mtrl.line_id
    AND IN we.wip_entity_name
    ("8OAS4781EBR3011",
    "8OAS4781EBT3007,"
    "91AS7382EBR3003,"
    '91AS7382EBT3001 '.
    );

    Expected results:
    ....... Line_ID Inventory_Item_ID Remaining_Qty Total_Rem_Qty
    3066336 259376 150 150
    2884782 259378 228 378
    3066336 259378 150 378
    2884782 281571 228 228

    I need the total remaining qty based on the inventory_item_id (specimen o/p 2 & 3).

    Thanks in advance.

    You can either use functions of aggregation or analytical functions according to your requirement.

    You did not mention exactly how your output should look like.

    If you want the sum of the remaining_qty then

    Select inventory_id, sum (remaining_qty) of (your query)
    Inventory_id group.

    If you want to than the sum of the remaining_qty as well as your previous output
    then

    use

    Sum (remaining_qty) on total_rem_qty (inventory_id)

    Here, you don't need to use any group of.

    But it will be like a total cumulative.

    If it is not your problem, give us your expected results.

  • Help Needed in SQL query

    Hi all

    Required clarification of Oracle sql

    Example table:

    EmpNo empname mgr_id hire_date deptno salary Job

    7788 SCOTT ANALYST 7566 3000 APRIL 19, 87 20
    7902 7566 3000 3 DECEMBER ANALYST FORD 81 20
    7934 MILLER COMMITTED JANUARY 7782 1300 23 82 10
    7900 7698 DECEMBER 3, CLERK JAMES 81 950 30
    7369 SMITH COMMITTED 7902 17 DECEMBER 20 800 80
    7876 ADAMS 7788 1100 23 MAY CLERK 87 20


    Need of ' single / one ' sql for this statement of the obligation:

    There will be 2 dropdown boxes (1 - work list, 2nd - empno) in the form in which the next set of results is expected

    (1) when the user selects the value of the 1st drop down box (employment) as "ANALYST", leaving the second dropdown not selected, the expected result is 2 (No. lines for this work)
    (2) when the user selects the value of the 1st drop-down list (job) as "ANALYST" and the value in the 2nd drop-down box like 7902, the expected result is 1 (no lines for this job and empno)

    SQLs I tried on my side (given below) gave the expected result and do please help me fix this

    Select count (1) in the scott.emp where job = 'ANALYST' and (empno =: empno or empno is null);

    Please help for this requirement. Any help is deeply appreciated.

    Thank you
    Zakari

    1007144 wrote:

    SQLs I tried on my side (given below) gave the expected result and do please help me fix this

    Select count (1) in the scott.emp where job = 'ANALYST' and (empno =: empno or empno is null);

    You check "IS NULL" on EMPNO clolumn. You should check on the value passed: EMPNO. It should be

    select count(1) from scott.emp where job='ANALYST' and ( empno = :empno or :empno is null ) ;
    

    Published by: JAC on May 21, 2013 19:32
    Hope that the: value of EMPLOYMENT is required...

  • XML, Flex, e4x - need help

    Hello

    I'm trying to understand why I am unable to generate value in an alert or using "mx.utils.ObjectUtil.

    I have the following XML code that is returned by a call to RemoteObject. These data are then used in a < mx:Tree >

    < company >
    -name of the company = 'ABC Company' >
    < name of the contact id = "2" name = 'John Doe' / >
    < name of the contact id = "3" name = "Jane Doe" / >
    < / company >
    -< company name = 'Systems Z' >
    < contact id = "4" name = "Mark Doe" / >
    < / company >
    < / companies >

    The tree uses the attribute of 'change' and the lights of a method call. Here is this method.

    public void treeChanged(event:Event):void {}
    selectedNode = tree (event.target) .selectedItem;
    Alert.Show (SelectedNode.@Name);
    }

    This code works fine, but when I try exchanging @name to @id, because I'm trying ultimately a form of "detail" with more detailed information. So using @name gives me the name of the contact, but I really want the ID and how I got it, does not work for some reason when I use @id or @contactid

    Any help appreciated.

    -Westside

    Hello

    I ended up renaming it to "contactId" or something else, just not with 'id' as in my xml attribute. That seemed to work.

    -Westside

  • help needed in query select

    Hello

    I use the apex of oracle 10g 3.2
    I use a select statement inside a cursor in an anonymous PL/SQL process. The output of the query is like that.

    Method_id patient_id result index_repeat
    39 123 12 0
    29 123 23 0
    39 123 32 1

    Now what I want, that is if there is more then a method_id as 39 occurs twice with index_repeat 0 and 1, then take only with index 39 repeat 1 I mean the output of what I want is the select query

    Method_id patient_id result index_repeat
    29 123 23 0
    39 123 32 1

    I use the following query

    Select method_internal_index, result, patient_id_code, index_repeat
    of t_files_data_exp
    where f_id =: P56_F_ID

    F_ID is the primary key.

    Thank you
    Olivier

    Don't know what exactly you need. When I read your condition sounds like all you need is the following;

    select  method_internal_index
           ,patient_id_code
           ,result
           ,index_repeat
    from    t_files_data_exp
    where   f_id=:P56_F_ID
    and     index_repeat = 1
    

    However, I suspect that what you need is the following;

    select * from
    (
      select  *
             ,row_number() over (partition by method_id order by index_repeat desc) rn
      from    t_files_data_exp
      where   f_id=:P56_F_ID
    )
    where rn = 1
    

    because I assume that the INDEX_REPEAT could be 2 or 3 or more!

Maybe you are looking for