Unable to loop result set of a query in Site Studio component

Hi all

I write a custom component to display the records in the custom table.

I created a (docservice) service called 'GET_DATA_VIEW' and selected scriptable. In action, I've assigned a "Quser" query and the query "select type query cache. I gave the name of result as GET_USER set.

Now, the "Quser" query is a simple select statement as follows:

Select * from temp_user where dName =?.

Added dName as a parameter.

The studio site page when I run the service and the result set, the loop it does not work. The code is as below:

<!-$dName = 'test'->
<!-$ executeService ("GET_DATA_VIEW")->
<! - $loop GET_USER - >
<!-$dName->: <!-$dDepartment->
<!-$endloop->

It does not, so that if I create a page template in the component that works.

Help, please.

Leo30 wrote: my query is "select country countryname".

Where COUNTRYNAME is a column in the country table.

When trying to loop through the result set, it does not print the result as below:




>

Leo30 wrote: but when I print it gives me the correct number of rows in the table.

Hoping that the "USER_LIST" is a typo. The result set name is 'COUNTRY_LIST '.

In any case, assuming that the fault of typo, it is likely that you have the incorrect column name or the name of the column is in the wrong case. The names are case-sensitive, and you can not return the column name, you expect from the result set.

Try to use this code to print the actual column names and values of the result set.






=


Tags: Fusion Middleware

Similar Questions

  • Hotkey of the worksheet area of writing in the result set

    Y at - it a keyboard shortcut to switch between writing in the SQL worksheet and navigate (or copy,...) in the result set of a query run?

    That would make my job easier everyday!

    @Chris

    ALT + PagegDown in version 4.0

    No no not a nav of Ko to this v3.2 and earlier versions, has been saved as a bug.

  • Remove duplicates from the result set

    Here's a challenge question that I was playing with a my free time during the work.

    I assume you have the basic HR example somewhere around (I hope is not in production).

    Let's say you want to get employees from the employees table whose name is similar to another employee last name.
    The easiest way is to join the two tables with a join condition that checks for the name and employee id. Here's what I came with.

    *************

    Select e1.last_name, e1.first_name b, e2.last_name c, e2.first_name d
    employees employees join e1 e2
    on (e1.last_name = e2.employee_id <>e2.last_name and e1.employee_id)
    order by one;

    ************

    The above query returns 10 rows. The first and the second are essentially the same. It is similarly, 3 & 4, 5 & 6, 7 and 8 and 9 and 10. The question is: is there a way that allows me to get rid of using only sql duplicate rows from the result set of this query. I sat on it for 15 minutes and I couldn't know. I'll try to watch my completed work once again.

    Example:

    SQL> column a format a10
    SQL> column b format a10
    SQL> column c format a10
    SQL> column d format a10
    SQL>
    SQL>
    SQL> select e1.last_name a , e1.first_name b, e2.last_name c, e2.first_name d
      2  from employees e1 join employees e2
      3  on ( e1.last_name = e2.last_name and e1.employee_id != e2.employee_id)
      4  where e1.employee_id < e2.employee_id
      5  order by a;
    
    A          B          C          D
    ---------- ---------- ---------- ----------
    Cambrault  Gerald     Cambrault  Nanette
    Grant      Kimberely  Grant      Douglas
    King       Steven     King       Janette
    Smith      Lindsey    Smith      William
    Taylor     Jonathon   Taylor     Winston
    
    SQL>
    
  • Help with the query to select only one record from the result set in double

    Hello

    Please help with the query. Version of Oracle database we use is 10g R2.

    I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec

    ID
    Org
    DF
    Sec Sub-Sec

    (163)CQCPDMCPDMHD(163)PCENGENGENG(163)CQASICASICIS8888TSTACTACTAC(163)TSHEHESW6789CQINFOINFOFOS6789PCSECSYSSECSYSINFO16789TSSECSYSSECSYSINFO29009PCBMSBMSBMS1

    My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.

    ID
    DSB

    DF
    SEC
    Sub-Sec
    (163)CQCPDMCPDMHD8888TSTACTACTAC6789CQINFOINFOFOS9009PCBMSBMSBMS1


    Thank you

    Orton

    Hello

    This sounds like a job for ROW_NUMBER:

    WITH got_r_num AS

    (

    SELECT id, DSB, df, s, sub_sec org

    ROW_NUMBER () OVER (PARTITION BY ID.

    ORDER BY org

    ) AS r_num

    OF view_x

    )

    SELECT id, DSB, df, sub_sec s,

    OF got_r_num

    WHERE r_num = 1

    ;

    He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data.  (I know that you said that you were a view selection.  Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
    Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.  (I didn't quite understand the explanation above.  I don't know why you want to

    ID ORG DF DRY SUB_SEC

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

    1234 CQ DPRK DPRK HD

    and is not

    1234 IS CQ ASIC, ASIC

    or

    TS 1234 IT IT SW

    or

    1234 CQ ASIC ASIC HD

    )
    If you change the query at all, post your modified version.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • Query result set...

    I can't determine a good word in my question. So, I think that my pseudocode below will be sufficient for this purpose.

    Oracle version: 11.2 g

    Data set
    WITH temp AS
    (
     SELECT 1 col1, 1 day FROM dual UNION ALL
     SELECT 2 col1, 1 day FROM dual UNION ALL
     SELECT 3 col1, 1 day FROM dual UNION ALL
     SELECT 4 col1, 1 day FROM dual UNION ALL
     SELECT 5 col1, 1 day FROM dual UNION ALL
     SELECT 6 col1, 1 day FROM dual UNION ALL
     SELECT 7 col1, 2 day FROM dual UNION ALL
     SELECT 8 col1, 2 day FROM dual UNION ALL
     SELECT 9 col1, 2 day FROM dual UNION ALL
     SELECT 10 col1,2 day FROM dual 
    )
    SELECT *
      FROM temp
    The result of the above query:
    COL1     DAY
    1     1
    2     1
    3     1
    4     1
    5     1
    6     1
    7     2
    8     2
    9     2
    10     2
    You the WISH result set:
    DAY COL_TOTAL
    1   21  
    2   55   -- 21 + 33 (the sum of day 1 + the sum of day 2)
    I realize that I can get the desired result, set above the code below. However, for my I have several other data points and 100 separate days I need to do for their actual issue. In doing so, a statement of the UNION 100 isn't exactly going to work.
    WITH temp AS
    (
     SELECT 1 col1, 1 day FROM dual UNION ALL
     SELECT 2 col1, 1 day FROM dual UNION ALL
     SELECT 3 col1, 1 day FROM dual UNION ALL
     SELECT 4 col1, 1 day FROM dual UNION ALL
     SELECT 5 col1, 1 day FROM dual UNION ALL
     SELECT 6 col1, 1 day FROM dual UNION ALL
     SELECT 7 col1, 2 day FROM dual UNION ALL
     SELECT 8 col1, 2 day FROM dual UNION ALL
     SELECT 9 col1, 2 day FROM dual UNION ALL
     SELECT 10 col1,2 day FROM dual 
    )
    SELECT SUM(col1) AS col_total
      FROM temp
     WHERE day <= 1
    UNION ALL
    SELECT SUM(col1) AS col_total
      FROM temp
     WHERE day <= 2
    Published by: user652714 on August 13, 2012 21:55

    Hello

    I now see what you want. You can use this:

    select *
    from tt
    order by col_1;
    
         COL_1        DAY
    ---------- ----------
             1          1
             2          1
             3          1
             4          1
             5          1
             6          1
             7          2
             8          2
             9          2
            10          2
    
    10 rows selected.
    
    select day, sum(total) over  (order by  day) COL_TOTAL
    from
    (select day, sum(col_1) TOTAL
    from tt
    group by day
    );
    
        DAY  COL_TOTAL
    ---------- ----------
             1         21
             2         55
    
    2 rows selected.
    
  • Problem with the query result set * STILL a QUESTION *.

    Summary

    What I am tring to do is to return output to the data points that currently have no values.

    * Here it is sample data for reasons explaining my question (my data set is MUCH bigger)

    xTable
    YEAR    PEOPLE    ITEMS    TYPE_NUMBER TYPE_DESC    CLASS
    2010       1                 1              REG              1 
    2010        2        3         2             MISC             1
    2010        5        4         3             WEEK           1
    2010                             1             REG              2
    2010                             2             MISC             2
    2010                             3             WEEK           2
    2009       1                 1              REG              1 
    2009        2        3         2             MISC             1
    2009        5        4         3             WEEK           1
    2009                             1             REG              2
    2009                             2             MISC             2
    2009                             3             WEEK           2
    
    ... (there's over 100 other unique CLASS values)
    Desired output
    YR     PEOPLE   ITEMS   TOTAL PEOPLE  TOTAL_ITEMS
    2010         -            -            -                        -                         --  (Class 2 result set)
    
    /* FYI, If i wanted the class 1 result set it would look like this:
    YR     PEOPLE   ITEMS   TOTAL PEOPLE  TOTAL_ITEMS
    2010        8       7             16                    14                       -- (Class 1 result set)*/
    Oracle: 10.2 G
            select 2010 as yr,
                         nvl(f.people,'-') as people
                         nvl(f.items,'-') as items  
                         nvl(to_char(sum(f.people)),'-') as total_people,
                         nvl(to_char(sum(f.items)),'-') as total_items,
                         from Xtable,
                              (2010 as yr,
                              sum(items)as items
                              sum(people) as people
                              from xTable
                              where person_id = 99999
                              and   type_number in (1,2,3)
                              and year = 2010
                              and class = 2 
                              or class = 1
                              ) f
                         where person_id = 99999
                         and type_number in (1,2,3)
                         and yr = f.yr
                         and (year <= 2010 or year = 2010)
                         and (class = 2 or class = 1)
                         group by 
                         f.people,
                         f.items
    Currently, the query above will return no rows.

    Published by: user652714 on February 2, 2010 13:04

    How about this?

    SQL> WITH    xTable AS
      2  (
      3          SELECT 2010 AS YEAR, 1 AS PEOPLE, 0 AS ITEMS, 1 AS TYPE_NUMBER, 'REG' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      4          SELECT 2010 AS YEAR, 2 AS PEOPLE, 3 AS ITEMS, 2 AS TYPE_NUMBER, 'MISC' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      5          SELECT 2010 AS YEAR, 5 AS PEOPLE, 4 AS ITEMS, 3 AS TYPE_NUMBER, 'WEEK' AS TYPE_DESC, 1 AS CLASS FROM DUAL UNION ALL
      6          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 1 AS TYPE_NUMBER, 'REG' AS TYPE_DESC, 2 AS CLASS FROM DUAL UNION ALL
      7          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 2 AS TYPE_NUMBER, 'MISC' AS TYPE_DESC, 2 AS CLASS FROM DUAL UNION ALL
      8          SELECT 2010 AS YEAR, NULL AS PEOPLE, NULL AS ITEMS, 3 AS TYPE_NUMBER, 'WEEK' AS TYPE_DESC, 2 AS CLASS FROM DUAL
      9  )
     10  -- END SAMPLE DATA
     11  SELECT  YEAR
     12  ,       NVL(TO_CHAR(SUM(PEOPLE)),'-')    AS PEOPLE
     13  ,       NVL(TO_CHAR(SUM(ITEMS)),'-')     AS ITEMS
     14  ,       CLASS
     15  FROM    xTable
     16  WHERE   CLASS IN (1,2)
     17  AND     YEAR = 2010
     18  GROUP BY YEAR
     19  ,       CLASS
     20  ORDER BY CLASS DESC;
    
                    YEAR PEOPLE ITEMS CLASS
    -------------------- ------ ----- -----
                    2010 -      -         2
                    2010 8      7         1
    
  • Set up a query (written Re)

    Hi Experts,

    I am facing a problem in executing the query that take a long time. And I'm new to setting up a query, kindly help me in this query to reduce the time of execution below.

    After reading the stories, I am unable to find how to get the execution of the query, but not sure about re writing the query plan. This is the execution plan.

    Please help me by rewriting the query and guide me some ground rules for rewriting where needed.

    203 rows selected.
    
    Execution Plan
    ----------------------------------------------------------
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=5745 Card=1 Bytes=
              222)
    
    
       1    0   SORT (GROUP BY NOSORT) (Cost=5570 Card=1 Bytes=12)
       2    1     TABLE ACCESS (FULL) OF 'FAMIS_REQ' (TABLE) (Cost=5570 Ca
              rd=1 Bytes=12)
    
    
       3    0   SORT (GROUP BY NOSORT) (Cost=5563 Card=1 Bytes=8)
       4    3     TABLE ACCESS (FULL) OF 'FAMIS_REQ' (TABLE) (Cost=5563 Ca
              rd=1 Bytes=8)
    
    
       5    0   NESTED LOOPS (OUTER) (Cost=5745 Card=1 Bytes=222)
       6    5     FILTER
       7    6       NESTED LOOPS (OUTER) (Cost=5743 Card=1 Bytes=198)
       8    7         NESTED LOOPS (OUTER) (Cost=5742 Card=1 Bytes=163)
       9    8           HASH JOIN (Cost=5739 Card=1 Bytes=140)
      10    9             NESTED LOOPS
      11   10               NESTED LOOPS (Cost=5567 Card=1 Bytes=98)
      12   11                 TABLE ACCESS (FULL) OF 'FAMIS_REQ' (TABLE) (
              Cost=5565 Card=1 Bytes=90)
    
    
      13   11                 INDEX (RANGE SCAN) OF 'FAMIS_REQUESTOR1' (IN
              DEX) (Cost=1 Card=1)
    
    
      14   10               TABLE ACCESS (BY INDEX ROWID) OF 'FAMIS_REQUES
              TOR' (TABLE) (Cost=2 Card=1 Bytes=8)
    
    
      15    9             TABLE ACCESS (FULL) OF 'FAM_PERSON' (TABLE) (Cos
              t=172 Card=1074 Bytes=45108)
    
    
      16    8           TABLE ACCESS (BY INDEX ROWID) OF 'LEASE_CONTACT' (
              TABLE) (Cost=3 Card=1 Bytes=23)
    
    
      17   16             INDEX (RANGE SCAN) OF 'FK_LEASECONTACT_CONTACT'
              (INDEX) (Cost=1 Card=1)
    
    
      18    7         TABLE ACCESS (BY INDEX ROWID) OF 'LEASE' (TABLE) (Co
              st=1 Card=1 Bytes=35)
    
    
      19   18           INDEX (UNIQUE SCAN) OF 'PK_LEASE' (INDEX (UNIQUE))
               (Cost=0 Card=1)
    
    
      20    5     TABLE ACCESS (BY INDEX ROWID) OF 'FAMIS_LEASE_LOCATION'
              (TABLE) (Cost=2 Card=1 Bytes=24)
    
    
      21   20       INDEX (RANGE SCAN) OF 'FAMIS_LEASE_LOC_LEASE_FK' (INDE
              X) (Cost=1 Card=1)
    
    
    
    
    
    
    
    
    
    
    Statistics
    ----------------------------------------------------------
              0  recursive calls
              0  db block gets
        8484854  consistent gets
              0  physical reads
              0  redo size
          34190  bytes sent via SQL*Net to client
           9592  bytes received via SQL*Net from client
             15  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
            203  rows processed
    
    
    SQL>
    

    Apologies for any inconvenience in the reading of the application. This is the query.

    SELECT a.req_number, a.req_status, a.wo_number, a.wo_status, a.description,
              a.requestor, a.req_date, a.enter_date, a.pl_number, a.site,
              a.building, a.room, a.attribute2, b.emp_id, c.custom09, c.custom13,
              c.custom11, c.custom16 + 1 AS family_no, c.active_flag, e.leaseid,
              e.commdate, e.enddate, e.functional_status, f.site_code,
              CASE
                 WHEN c.custom09 = 'Married'
                    THEN 10
                 ELSE 0
              END AS married,
              CASE
                 WHEN (CASE
                          WHEN (c.custom16 + 1) > 4
                             THEN 10
                          ELSE (c.custom16 + 1) * 2
                       END
                      ) IS NULL
                    THEN 0
                 ELSE (CASE
                          WHEN (c.custom16 + 1) > 4
                             THEN 10
                          ELSE (c.custom16 + 1) * 2
                       END)
              END AS family,
              CASE
                 WHEN c.custom11 = 'Canadian Management'
                    THEN 8
                 ELSE 0
              END AS job,
              CASE
                 WHEN (  CASE
                            WHEN MONTHS_BETWEEN (SYSDATE,
                                                 TO_DATE (c.custom13,
                                                          'MM/DD/YYYY')
                                                ) > 36
                               THEN 6
                            ELSE 0
                         END
                       + CASE
                            WHEN MONTHS_BETWEEN (SYSDATE,
                                                 TO_DATE (c.custom13,
                                                          'MM/DD/YYYY')
                                                ) > 36
                               THEN   (  MONTHS_BETWEEN (SYSDATE,
                                                         TO_DATE (c.custom13,
                                                                  'MM/DD/YYYY'
                                                                 )
                                                        )
                                       - 36
                                      )
                                    / 24
                            ELSE   MONTHS_BETWEEN (SYSDATE,
                                                   TO_DATE (c.custom13,
                                                            'MM/DD/YYYY'
                                                           )
                                                  )
                                 / 24
                         END
                      ) IS NULL
                    THEN 0
                 ELSE (  CASE
                            WHEN MONTHS_BETWEEN (SYSDATE,
                                                 TO_DATE (c.custom13,
                                                          'MM/DD/YYYY')
                                                ) > 36
                               THEN 6
                            ELSE 0
                         END
                       + CASE
                            WHEN MONTHS_BETWEEN (SYSDATE,
                                                 TO_DATE (c.custom13,
                                                          'MM/DD/YYYY')
                                                ) > 36
                               THEN   (  MONTHS_BETWEEN (SYSDATE,
                                                         TO_DATE (c.custom13,
                                                                  'MM/DD/YYYY'
                                                                 )
                                                        )
                                       - 36
                                      )
                                    / 24
                            ELSE   MONTHS_BETWEEN (SYSDATE,
                                                   TO_DATE (c.custom13,
                                                            'MM/DD/YYYY'
                                                           )
                                                  )
                                 / 24
                         END
                      )
              END AS hire,
              CASE
                 WHEN MONTHS_BETWEEN (SYSDATE, a.req_date) * 4 > 10
                    THEN 10
                 ELSE MONTHS_BETWEEN (SYSDATE, a.req_date) * 4
              END AS entered,
                CASE
                   WHEN c.custom09 = 'Married'
                      THEN 10
                   ELSE 0
                END
              + CASE
                   WHEN (CASE
                            WHEN (c.custom16 + 1) > 4
                               THEN 10
                            ELSE (c.custom16 + 1) * 2
                         END
                        ) IS NULL
                      THEN 0
                   ELSE (CASE
                            WHEN (c.custom16 + 1) > 4
                               THEN 10
                            ELSE (c.custom16 + 1) * 2
                         END
                        )
                END
              + CASE
                   WHEN c.custom11 = 'Canadian Management'
                      THEN 8
                   ELSE 0
                END
              + CASE
                   WHEN (  CASE
                              WHEN MONTHS_BETWEEN (SYSDATE,
                                                   TO_DATE (c.custom13,
                                                            'MM/DD/YYYY'
                                                           )
                                                  ) > 36
                                 THEN 6
                              ELSE 0
                           END
                         + CASE
                              WHEN MONTHS_BETWEEN (SYSDATE,
                                                   TO_DATE (c.custom13,
                                                            'MM/DD/YYYY'
                                                           )
                                                  ) > 36
                                 THEN   (  MONTHS_BETWEEN (SYSDATE,
                                                           TO_DATE (c.custom13,
                                                                    'MM/DD/YYYY'
                                                                   )
                                                          )
                                         - 36
                                        )
                                      / 24
                              ELSE   MONTHS_BETWEEN (SYSDATE,
                                                     TO_DATE (c.custom13,
                                                              'MM/DD/YYYY'
                                                             )
                                                    )
                                   / 24
                           END
                        ) IS NULL
                      THEN 0
                   ELSE (  CASE
                              WHEN MONTHS_BETWEEN (SYSDATE,
                                                   TO_DATE (c.custom13,
                                                            'MM/DD/YYYY'
                                                           )
                                                  ) > 36
                                 THEN 6
                              ELSE 0
                           END
                         + CASE
                              WHEN MONTHS_BETWEEN (SYSDATE,
                                                   TO_DATE (c.custom13,
                                                            'MM/DD/YYYY'
                                                           )
                                                  ) > 36
                                 THEN   (  MONTHS_BETWEEN (SYSDATE,
                                                           TO_DATE (c.custom13,
                                                                    'MM/DD/YYYY'
                                                                   )
                                                          )
                                         - 36
                                        )
                                      / 24
                              ELSE   MONTHS_BETWEEN (SYSDATE,
                                                     TO_DATE (c.custom13,
                                                              'MM/DD/YYYY'
                                                             )
                                                    )
                                   / 24
                           END
                        )
                END
              + CASE
                   WHEN MONTHS_BETWEEN (SYSDATE, a.req_date) * 4 > 10
                      THEN 10
                   ELSE MONTHS_BETWEEN (SYSDATE, a.req_date) * 4
                END
              + CASE
                   WHEN a.attribute2 IS NULL
                      THEN '0'
                   ELSE a.attribute2
                END AS total,
              CASE
                 WHEN f.site_code IN ('AJ1', 'AJ2', 'AJ3', 'RG1')
                    THEN f.building_code
                 ELSE f.space_code
              END AS SPACE,
              CASE
                 WHEN a.site IN ('AJ1', 'AJ2', 'AJ3', 'RG1')
                    THEN a.building
                 ELSE a.room
              END AS space_req,
              CASE
                 WHEN a.pl_number = '002002001'
                    THEN 'Villa to Villa'
                 ELSE (CASE
                          WHEN a.pl_number = '002002002'
                             THEN 'Apartment to Villa'
                          ELSE (CASE
                                   WHEN a.pl_number = '002002003'
                                      THEN 'Apartment to Apartment'
                                   ELSE 'Villa to Apartment'
                                END
                               )
                       END
                      )
              END AS TYPE,
              (SELECT   MAX (g.req_date)
                   FROM famis_req g
                  WHERE g.req_date < a.req_date
                    AND g.requestor_id = a.requestor_id
                    AND g.pl_number IN
                             ('002002001', '002002002', '002002003', '002002004')
                    AND g.wo_status = 'CLOSED'
               GROUP BY g.requestor_id) AS last_move,
              (SELECT   COUNT (g.req_number)
                   FROM famis_req g
                  WHERE g.req_date <> a.req_date
                    AND g.requestor_id = a.requestor_id
                    AND g.pl_number IN
                             ('002002001', '002002002', '002002003', '002002004')
                    AND g.req_status NOT IN ('REJECTED', 'CANCELED')
               GROUP BY g.requestor_id) AS requests
         FROM famis_req a JOIN famis_requestor b ON a.requestor_id =
                                                                    b.requestor_id
              JOIN fam_person c ON b.emp_id = c.person_code
              LEFT JOIN lease_contact d ON c.person_code = d.contact_id
              LEFT JOIN lease e ON d.leaseid = e.leaseid
              LEFT JOIN famis_lease_location f ON e.leaseid = f.lease_code
        WHERE site <> 'CNAQ1'
          AND pl_number IN ('002002001', '002002002', '002002003', '002002004')
          AND (a.enter_date < e.enddate OR e.enddate IS NULL)
          AND (e.functional_status = 'OCCUPIED' OR e.functional_status IS NULL)
    

    Thank you.

    It is difficult to read anything not formatted output of the explain plan.

    In any case, there is a hughe number of becomes coherent.

    I'm just guessing that the reason might be the two groups of subqueries.

    You can try to replace them with

    1 Inline views or subquery (with article) plants which are connected to the result set

    or

    2 analysis functions

    Here is an example of the latter approach. You can try if this changes something (after make sure you that they lead to correct results).

    , max (case when a.wo_status = 'CLOSED' then a.req_date any other purpose) over (partition by a.requestor_id of a.req_date order

    range between unbounded preceding and interval "0.1"(seconde précédant) as last_move "."

    , count (case when not in a.req_status ('DENIED', 'CANCELLED') then a.req_number any other purpose))

    a.requestor_id partition)

    -count (case when not in a.req_status ('DENIED', 'CANCELLED') then a.req_number any other purpose))

    partition a.requestor_id, a.req_date) as applications

    Note that I assume that req_date is of date data type. If it is of type timestamp, the interval should be adapted.

  • Group by result set divergence

    Hi all

    Please help me on below.

    When I group by result set is as below.

    SQL > select count (*), the Group of the stg_famis_equip, by attribut2, attribut2 having count (*) > 1;

    COUNT (*) ATTRIBUT2

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

    2 FM023566                                                            

    2 FM021481                                                            

    2 FM025833                                                            

    2 FM058806                                                            

    Where, if I query with WHERE clause for certain values as below.

    Please suggest me on, why it is show as count = 2 and when questioning with only WHERE clause (some time no record).  I do one any error... Please suggest me.

    SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM023566';

    ATTRIBUT2 ATTRIBUT3

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

    FM023566 12

    SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM021481';

    ATTRIBUT2 ATTRIBUT3

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

    FM021481 11

    FM021481 12

    SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM025833';

    ATTRIBUT2 ATTRIBUT3

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

    FM025833 07

    FM025833 12

    SQL > select attribut2, attribut3 from stg_famis_Equip where attribut2 = 'FM058806';

    no selected line

    I'm on the Oracle 11 g Enterprise Edition Release Database 11.2.0.2.0 - 64 bit Production

    Thank you

    This means that:

    FM023566 has the new line and return at the end of the string (13/10)

    FM021481 is clean

    FM025833 is also clean

    FM058806 has the new line and carriage return to then end of the string

    Trim will replace spaces when not specified what should be trimmed. If you could do a RTRIM (attribute2, CHR (13): 10 to clean the data.)

    HTH

  • How to enable the Java Script function in APEX 4.2.6 running on the result of an Xquery query.

    How to take a SQL query result in the source section of an APEX "agenda of the page" field and allow this request to be formatted using XML in an HTML format for a Java Script file to perform a function on the result?

    Currently I have the following text:

    To query the DB table and format the result as HTML:

    SELECT XMLELEMENT ("UL id ="ticker01"', XMLAGG (XMLFOREST (Scroll_Mess AS LI))") "item UL' OF Web_Ticker where Mess_Id < 10 order by Mess_Id;


    That displays the following:


    < UL id = "ticker01" > < LI > HELLO < /LI > < LI > HELLO < /LI > < /UL id = "ticker01" >

    I need the output of this to be visible to a JScript function that is currently called the "head of page", but there doesn't seem to be its scope? The function works correctly if there is a list in the page field items 'Text element Pre' but does not work correctly when used in conjunction with the query to generate a table form.

    If everyone is happy to help I would be grateful .

    James.

    Solved!

    In order for the request to be part of the DOM of the page of the APEX, the Java Script allows to perform its function on the result marked "HTML" to query, you must set page of the apex on which the query resides and then add the inner text of this page to a second variable for which the function of web ticker can run on as follows:

    $(function() {})

    var x = $("#P9_TICKER_DATA");

    var y = x [0] .innerText;

    x.Append (y);

    $("UL#ticker01").liScroll ();

    });

    From there, on the Java script is able to properly see the result of the query in HTML format.

  • UNION and UNION ALL giving multiple result sets even if INTERSECT does not lines.

    Hello

    I have a set of two queries. I used the UNION to join the result set. When I used UNION ALL, I get a different result set.

    BT when I use INTERSECT, I m not getting all the lines.

    SO, which I guess is, as operation INTERSECT isn't Govind all the lines, then the UNION and UNION ALL of the result sets must be simliar.

    But I m getting different result sets.

    Please guide me.

    Thank you.

    Hello

    UNION returns separate lines; UNION ALL returns all rows that produce queries.

    INTERSECT has nothing to do with it.  You can have the lines in a single query.  For example

    Job SELECTION

    FROM scott.emp

    UNION - ALL THE

    SELECT 'FUBAR '.

    DOUBLE;

    In this example, there is no overlap between the 2 queries (INTERSECT would have 0 rows).

    UNION produces 6 lines, because the query at the top of the page produces 5 distinct lines (of 14 total ranks) and the background query 1.

    UNION ALL product lines 15: 14 of the request from top and 1 of the request from the lower part.

    I hope that answers your question.

    If not, post a test script (if necessary) and complete, including some UNION, UNION ALL queries INTERSECT.  Post of the CREATE TABLE and INSERT statements for all tables using those queries (with the exception of the commonly available rtables, such as those of the scott schema) and a specific question, such as "the UNION query all product...» I expect the UNION query to produce... because... but instead, it produces... Why is this?  It seems contractict... manual which says that... ».

  • Need help to restrict to a result set of a UNION in FUSION

    Hello

    Would be really grateful if someone could help me with the problem I am facing with the statements below (I'm new to Oracle ):

    merge into table_name_1 p

    using

    (

    Select p_key, value_1, value_2

    of some_tables

    UNION

    Select p_key, value_1, value_2

    of some_tables

    UNION

    .....;

    ) t

    on (p.p_key = t.p_key)

    When matched then

    Update table_name_1 with value_1 and value_2

    When not matched then

    Insert table_name_1 with p_key, value_1 value_2;

    Now, the union of all these selects me gives distinct values and it works most of the time, but when I have values like below, the merge fails:

    p_key - value_1 - value_2

    100 25-50

    100 NULL - 50

    I scoured the net and understand the reason behind it: the result set becomes ambiguous and fusion does not know what line to insert first and including an update.

    Now my requirement is: I might sub sets of scenario/result of the union and I need only 1 row by p_key.

    result_set_1

    p_key - value_1 - value_2

    100 - 25-50 * need this line

    100 NULL - 50

    100 - NULL NULL

    result_set_2

    p_key - value_1 - value_2

    100-25 - NULL * need this line

    100 - NULL NULL

    result_set_3

    p_key - value_1 - value_2

    100-25 - NULL * need to this line (p_key = 100)

    100 - NULL NULL

    NULL 200-75 * need to this line (p_key = 200)

    200 - NULL NULL

    300 - 90-95 * need to this line (p_key = 300)

    So, I need basically a way to restrict the values I get from the UNION of all who selects to adapt to the requirement above, hope, I was able to explain the issue I'm facing.

    Any help would be greatly appreciated.

    Thank you

    Dpunk

    Calculate a value of priority for each line according to whether the columns are null or not, stopped by this value in the game for each p_key and take the first (highest) priority. I made a more important than value_2 value_1:

    Select p_key, value_1, value_2 of

    (select value_1, p_key, row_number() and value_2 to the course

    (p_key partition

    order of cases when value_1 is null then 0 2 other end +.

    cases where value_2 is null then 0 otherwise 1 end

    / / DESC

    ): the nurse

    (your query UNION here)

    )

    where rn = 1

    /

  • Get an empty result set but not null

    Hello

    I try to get all the rows in a table, it's inside a database to ORACLE 10 g using JRE 1.5.

    The connection is made.
    When I do executequery, it works well (whitout exceptions), the problem is that I'm a non-null result set, but it is empty.
    When I run the query directly in SQLDeveloper, sqlplus and TOAD he recover 12 rows, in this case I did not error in the search criteria and the query syntax is correct.

    Please helpme with a few suggestions or references.

    CRGM

    Your the log output does not show this line
    >
    If (rs! = null) {}
    System.out.println ("CRGM: is not null" "");
    >
    You said initially
    >
    the problem is that I'm a non-null result set, but it is empty
    >
    But if it was true we output the log to the top line.

  • Generate a single XML file of the multiple JDBC result set

    Hello

    I need to create a single XML file of the multiple result set. The code below is to generate a XML signle leave a single result set, but suppose we have five different tables in the same database and the tables aren't relalted to the other.

    for example: select * from SAMPLE_PRODUCT
    Select * command
    Select * LOGISTICS... and many others.


    You can create multiple sets of results by top queries but how can write all values using a JDBC result set in a single xml file? Help, please.

    a signle file xml from one generator result

    import java.io.StringWriter;
    import java.sql.Connection;
    to import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;

    Import javax.xml.parsers.DocumentBuilder;
    Import javax.xml.parsers.DocumentBuilderFactory;
    Import javax.xml.transform.OutputKeys.
    Import javax.xml.transform.Transformer;
    Import javax.xml.transform.TransformerFactory;
    Import javax.xml.transform.dom.DOMSource;
    Import javax.xml.transform.stream.StreamResult;

    to import org.W3C.DOM.document;
    Import org.w3c.dom.Element;

    public class JDBCToXML {}

    Public Shared Sub main (string args []) throws Exception {}
    DocumentBuilderFactory plant = DocumentBuilderFactory.newInstance ();
    DocumentBuilder builder = factory.newDocumentBuilder ();
    Doc document = builder.newDocument ();
    Element results = doc.createElement ("Results");
    doc.appendChild (results);

    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager
    .getConnection("jdbc:odbc:RIS","USER","USER");

    ResultSet rs = con.createStatement () .executeQuery ("select * from SAMPLE_PRODUCT");

    ResultSetMetaData rsmd = rs.getMetaData ();
    int colCount = rsmd.getColumnCount ();

    While (RS. Next {}
    Element line = doc.createElement ("Row");
    results.appendChild (row);
    for (int i = 1; i < = colCount; i ++) {}
    String columnName = rsmd.getColumnName (i);
    Object value = rs.getObject (i);
    Element node = doc.createElement (columnName);
    node.appendChild (doc.createTextNode (value.toString (()));
    row.appendChild (node);
    }
    }
    DOMSource domSource = new DOMSource (doc);
    TransformerFactory tf = TransformerFactory.newInstance ();
    Transformer transformer = tf.newTransformer ();
    transformer.setOutputProperty (OutputKeys.OMIT_XML_DECLARATION, 'yes');
    transformer.setOutputProperty (OutputKeys.METHOD, "xml");
    transformer.setOutputProperty (OutputKeys.ENCODING, "ISO-8859-1");
    StringWriter sw = new StringWriter();
    StreamResult sr = new StreamResult (sw);
    transform. Transform (domSource, sr);

    System.out.println (SW. ToString());

    con. Close;
    RS. Close();
    }
    }

    Thank you
    Sumit

    Published by: user8687839 on April 4, 2012 23:04

    Published by: user8687839 on April 4, 2012 23:09

    As EJP says, you really want to get the data in a single request, if possible (and I don't see why that shouldn't be the case).
    In fact, you really want to get this query to return the data as close the format you need as you can.

    If you did this on Oracle, for example, I'd get Oracle to produce XML that you can then turn (assuming that you could not itself produce the XML you want directly).
    In your case, using some db (access?), and then just get the line structure such as the conversion to XML involves the least amount of faffing about.

    Rethink the SQL and the rest should be easy.

  • How to merge several pull random requests in a result set?

    See tables: http://dl.dropbox.com/u/10356431/Shared/screen.png

    Can someone help me build a query that will randomly get questions based on the category and the level of difficulty and the total number of questions in the Question Set Config. table.

    I built a.

    SELECT c.question_id
    s.question_set_id
    OF qm_question_category c
    s qm_question_set_cfg
    WHERE (c.category_id = s.category_id
    AND c.difficulty_level = s.difficulty_level
    )
    AND ROWNUM < = (SELECT SUM (total_questions)
    OF qm_question_set_cfg
    WHERE question_set_id = 101138) / * Set ID * /.
    ORDER BY dbms_random.value

    It retrieves the total number of questions randomly from the existing questions based on the categories and the level of difficulty.

    But what I want is to * first go get the questions in each category + difficulty at random, then merge these lines * in a single result set. (For eg. 10 questions random category 1, Category2 10 to 10 of CategoryN as stated in the Question Set Config)

    Hello.

    Here's one way:

    --'sample data'
    WITH questions AS
    (
         SELECT
              LEVEL question_id,
              'Q'||LPAD(LEVEL,3,'0')||'?' question_text FROM DUAL
         CONNECT BY LEVEL <=500
    ),
    question_category AS
    (
         SELECT
              10-MOD(LEVEL,10) category_id,
              LEVEL question_id,
              MOD(LEVEL,3)+1 difficulty_level
         FROM dual
         CONNECT BY LEVEL <=1000
    ),
    question_set AS
    (
         SELECT 1 set_id, 'set_1' set_name FROM DUAL UNION
         SELECT 2 set_id, 'set_2' set_name FROM DUAL
    ),
    question_set_config AS
    (
         SELECT 1 set_config_id, 1 set_id, 1 category_id, 3 difficulty_level, 3 no_of_questions FROM dual UNION
         SELECT 2 set_config_id, 1 set_id, 2 category_id, 2 difficulty_level, 5 no_of_questions FROM dual UNION
         SELECT 3 set_config_id, 2 set_id, 3 category_id, 2 difficulty_level, 4 no_of_questions FROM dual UNION
         SELECT 4 set_config_id, 2 set_id, 4 category_id, 1 difficulty_level, 6 no_of_questions FROM dual
    ),
    ------------------------ 'end of sample data' ----------------------------------
    questions_categories AS
    (
         SELECT
              qc.category_id,
              q.question_id,
              q.question_text,
              qc.difficulty_level,
              ROW_NUMBER() OVER (PARTITION BY qc.category_id,qc.difficulty_level ORDER BY dbms_random.value) rn
         FROM
              questions q,
              question_category qc
         WHERE
              q.question_id = qc.question_id
    )
    SELECT
         qs.set_id,
         qc.question_id,
         qc.question_text,
         qc.category_id,
         qc.difficulty_level
    FROM
         question_set_config qsc,
         question_set qs,
         questions_categories qc
    WHERE
         qsc.set_id = qs.set_id AND
         qsc.difficulty_level = qc.difficulty_level AND
         qsc.category_id = qc.category_id AND
         qc.rn <= qsc.no_of_questions
    ORDER BY 1,4;
    
    SET_ID     QUESTION_ID     QUESTION_TEXT     CATEGORY_ID     DIFFICULTY_LEVEL
    ------     -----------     -------------     -----------     ----------------
    1     29          Q029?          1          3
    1     359          Q359?          1          3
    1     449          Q449?          1          3
    1     298          Q298?          2          2
    1     328          Q328?          2          2
    1     88          Q088?          2          2
    1     238          Q238?          2          2
    1     208          Q208?          2          2
    2     187          Q187?          3          2
    2     7          Q007?          3          2
    2     247          Q247?          3          2
    2     367          Q367?          3          2
    2     486          Q486?          4          1
    2     276          Q276?          4          1
    2     186          Q186?          4          1
    2     456          Q456?          4          1
    2     156          Q156?          4          1
    2     66          Q066?          4          1
    

    I hope this helps.

    Kind regards.

  • Combine queries to get the result set with max Y

    Hello
    I use forms 6i and db 10.2.0.1.0

    With the query below
    Select ufam_usrgrp,ufam_filegrp,ufam_read,ufam_write,ufam_overwrite,ufam_delete from usr_file_access_master
    Where ufam_ecode = '0004108';
    the result set is
    UFAM_USRGRP     UFAM_FILEGRP    UFA UFA UFA UFA
    --------------- --------------- --- --- --- ---
    MGMNT           CV              Y   Y   Y   Y
    EMPLOYEE        GENERAL         Y   N   N   N
    EMPLOYEE        PERSONAL        Y   N   N   N
    Another query
    Select uul_usrgrp, ufl_file_grp,ufl_read,ufl_write,ufl_overwrite,ufl_delete from usr_usrgrp_lnk,USRGRP_FILEGRP_LINK
    Where usr_usrgrp_lnk.uul_usrgrp = USRGRP_FILEGRP_LINK.UFL_USR_GRP
    and usr_usrgrp_lnk.uul_ecode = '0004108'
    gives the result
    UUL_USRGRP      UFL_FILE_GRP    UFL UFL UFL UFL
    --------------- --------------- --- --- --- ---
    MGMNT           GENERAL         Y   Y   Y   Y
    EMPLOYEE        GENERAL         Y   Y   N   N
    MGMNT           CV              Y   N   N   N
    I need to combine these two queries to get a separate result set with maximum Y

    Like here "MGMNT CV" is repeated in both the result set, but the first has more, then it should come from the combined result set. reverse-case also the same (such as "EMPLOYEE GENERAL")

    So I want to combine the queries so that I get the result as set below
    UserGroup       FileGroup       Rd Wrt Owrt Del
    --------------- --------------- --- --- --- ---
    MGMNT           GENERAL         Y   Y   Y   Y
    EMPLOYEE        GENERAL         Y   Y   N   N
    MGMNT           CV              Y   Y   Y   Y
    EMPLOYEE        PERSONAL        Y   N   N   N
    Please help me to combine these queries

    Published by: Divya on August 14, 2011 21:24
    Changed the result set and the last exit

    NOT TESTED!

    select y.uul_usrgrp,
           y.ufl_file_grp,
           greatest(ufl_read,nvl(ufam_read,' ')) ufl_read,
           greatest(ufl_write,nvl(ufam_write,' ')) ufl_write,
           greatest(ufl_overwrite,nvl(ufam_overwrite,' ')) ufl_overwrite,
           greatest(ufl_delete,nvl(ufam_delete,' ')) ufl_delete
      from (select ufam_usrgrp,ufam_filegrp,ufam_read,ufam_write,ufam_overwrite,ufam_delete
              from usr_file_access_master
             Where ufam_ecode = '0004108'
           ) x,
           (select uul_usrgrp, ufl_file_grp,ufl_read,ufl_write,ufl_overwrite,ufl_delete
              from usr_usrgrp_lnk,USRGRP_FILEGRP_LINK
             Where usr_usrgrp_lnk.uul_usrgrp = USRGRP_FILEGRP_LINK.UFL_USR_GRP
               and usr_usrgrp_lnk.uul_ecode = '0004108'
           ) y
     where y.uul_usrgrp = x.ufam_usrgrp(+)
       and y.ufl_file_grp = x.ufam_filegrp(+)
    

    Concerning

    Etbin

    Edited by: Etbin on 14.8.2011 13:08
    deleted by group

Maybe you are looking for