Hierarchial query returns ex-employees

I have query that was developed from the similar queries I've found on various sites. It display the hierarchy starting from our board of directors in a descending manner. The problem is that the query is pulling our "Ex-employees" which are identified by a person_type_id of 1123. The query is as follows.
SELECT LPAD ('->', 8 * (LEVEL - 1))
|| (SELECT DISTINCT full_name
FROM per_all_people_f
WHERE person_id = paf.person_id
AND PERSON_TYPE_ID <> '1123' -- 1123 = 'Ex-Employee'
AND SYSDATE BETWEEN effective_start_date
AND effective_end_date)
TREE
FROM per_all_assignments_f paf
WHERE SYSDATE BETWEEN paf.effective_start_date
AND paf.effective_end_date
AND paf.primary_flag = 'Y'
AND paf.person_id in (select pf.person_id from per_all_people_f pf where paf.person_id = pf.person_id and pf.PERSON_TYPE_ID <> '1123')
START WITH paf.person_id = (select person_id from per_all_people_f where last_name ='Board of') -- Board of Directors
CONNECT BY PRIOR paf.person_id = paf.supervisor_id
AND paf.primary_flag = 'Y'
AND paf.person_id in (select person_id from per_all_people_f pf where paf.person_id = pf.person_id and pf.PERSON_TYPE_ID <> '1123')
AND SYSDATE BETWEEN paf.effective_start_date
AND paf.effective_end_date
It returns info as follows (partial list). How do I eliminate the Ex-employees (blank lines except for ->?
Board of, Directors
->CEO, Jim
->CFO, Bill
->Doe, Jane
->Smith, Theresa
-> <-- ex-Employee
->Jones, Tammy
->
->
->
->
->
->Frank, Larry
->COO, Berny
->SSO, Jim

I believe you have more than one person_types for ex-employees in the table per_person_types. If that is that case, your query will fetch other ex-employees who have person_type_id different from 1123.
Hence it is always advisable to use person_type_id from the table per_person_type_usages_f and not from the table per_all_people_f.
For your case, I would suggest you try by making a join of per_all_prople_f and per_period_of_service whenever you have to exclude the ex-employees. Do not just believe on the condition 'where per_all_peopl_f.person_type_id != 1123 '
In the join you can use the condition 'where per_periods_of_service.actual_termination_date is null' (along with other conditions in the where clause)
Do let us know how it worked out.
Thanks.

Similar Messages

  • Need Hierarchial Query

    Hi All,
    I have below tables,
    Tables
    1 Employees Type (Tells About Employees Designation)
    2.Employee Details (Tells Employee Details)
    3.Employee Relation (Tells Relationship between Employees)
    Hierarchy
    ARC (SENIOR MANAGER)
    SUN (MANAGER)
    MOON (TECH LEAD)
    LITE (EMPLOYEE)
    RAG (TECH LEAD)
    BESH (TECH LEAD)
    CHESH (EMPLOYEE)
    PRASAD (EMPLOYEE)
    1 Employees Type Data
    Type No||Type Name
    1|Employee
    2|Tech Lead
    3|Manager
    4|Senior Manager
    2.Employee Details
    Emp No||Emp Name|Employee Type
    10|ARC|4
    20|SUN|3
    30|RAG|2
    40|PRASAD|1
    50|MOON|2
    60|LITE|1
    70|CHESH|1
    80|BESH|2
    3. Employee Relation
    Relation Number|Emp No|Prnt_Relation Number
    1|10|NULL
    2|20|1
    3|30|1
    4|40|1
    5|50|2
    6|60|2
    7|70|3
    8|80|3
    These are my tables structure,
    Now I want Hierarchial Query for below,
    Input will be Relation Number,
    if I give relation number as input I want to display all immediate childern that are Tech Leads and Employees only (it should ignore if it is having any Managers in the result set)
    Ex: -
    Input is relation number from Employee Relation Table,
    If I give input as *1*
    Output Should be,
    Relation Number|Employee_id|Employee Name
    3|30|Rag
    7|70|Besh
    8|80|Chesh
    If I give input as *2*
    Output Should be,
    Relation Number|Employee_id|Employee Name
    5|50|MOON
    6|60|LITE,
    If I give input as *4*
    Output Should be,
    Relation Number|Employee_id|Employee Name
    <NO Rows Returned>
    Thanks,

    Hi,
    with emp_type as (  select 1 type_id, 'Employee' emp_type from dual
    union
                        select 2 type_id, 'Tech Lead' emp_type from dual
    union
                        select 3 type_id, 'Manager' emp_type from dual
    union
                        select 4 type_id, 'Senior Manager' emp_type from dual),
    emp_details as (   select 10 emp_no, 'ARC' fname, 4 type1 from dual
    union
                            select 20 emp_no, 'SUN' fname, 3 type1 from dual
    union
                            select 30 emp_no, 'RAG' fname, 2 type1 from dual
    union
                            select 40 emp_no, 'PRASAD' fname, 1 type1 from dual
    union
                            select 50 emp_no, 'MOON' fname, 2 type1 from dual
    union
                            select 60 emp_no, 'LITE' fname, 1 type1 from dual
    union
                            select 70 emp_no, 'CHESH' fname, 1 type1 from dual
    union
                            select 80 emp_no, 'BESH' fname, 2 type1 from dual),
    Emp_Relation as (
    select 1 Relation, 10 emp_no1, null parent_Relation from dual
    union
    select 2 Relation, 20 emp_no1, 1 parent_Relation from dual
    union
    select 3 Relation, 30 emp_no1, 1 parent_Relation from dual
    union
    select 4 Relation, 40 emp_no1, 1 parent_Relation from dual
    union
    select 5 Relation, 50 emp_no1, 2 parent_Relation from dual
    union
    select 6 Relation, 60 emp_no1, 2 parent_Relation from dual
    union
    select 7 Relation, 70 emp_no1, 3 parent_Relation from dual
    union
    select 8 Relation, 80 emp_no1, 8 parent_Relation from dual)
    select  type_id, emp_type,
            emp_no, fname, relation, parent_relation
    from    EMP_DETAILS, EMP_TYPE, EMP_RELATION
    WHERE   TYPE_ID = type1
    AND     EMP_NO  = EMP_NO1
    AND     LEVEL = 2
    CONNECT BY PRIOR RELATION = PARENT_RELATION
    START WITH RELATION = :P_RELATION
    --START WITH PARENT_RELATION IS NULL -- If want to display the complete heirarchy remove comments for this line and remove "and level = 2" and  "START WITH RELATION = :P_RELATION"For p_relation = 1
       TYPE_ID EMP_TYPE           EMP_NO FNAME    RELATION PARENT_RELATION
             3 Manager                20 SUN             2               1
             2 Tech Lead              30 RAG             3               1
             1 Employee               40 PRASAD          4               1
    3 rows selected.Not sure how do you get the following and it's not clear on what basis.
    If I give input as *1*
    Output Should be,
    Relation Number|Employee_id|Employee Name
    3|30|Rag
    7|70|Besh
    8|80|CheshFor p_relation = 2
       TYPE_ID EMP_TYPE           EMP_NO FNAME    RELATION PARENT_RELATION
             2 Tech Lead              50 MOON            5               2
             1 Employee               60 LITE            6               2
    2 rows selected.For p_relation = 3
       TYPE_ID EMP_TYPE           EMP_NO FNAME    RELATION PARENT_RELATION
             1 Employee               70 CHESH           7               3
    1 row selected.For p_relation = 4
    no rows selected.Hope this helps
    Best Regards
    Arif Khadas
    Edited by: Arif Khadas on Jun 29, 2010 12:47 PM

  • Query help - Fetch employees working on two consecutive weekends(SAT/SUN)

    Hello Gurus,
    I have the following requirement and i need your help on this.
    We have a table with all employees effort logged in for the days they have worked. a sample data is given below
    TD_date     Emp_id     Effort     Archive_month
    2-Mar-13     123     8     Mar-13
    9-Mar-13     123     8     Mar-13
    2-Mar-13     213     4     Mar-13
    3-Mar-13     213     4     Mar-13
    24-Mar-13     213     8     Mar-13
    9-Mar-13     312     4     Mar-13
    10-Mar-13     312     4     Mar-13
    16-Mar-13     312     8     Mar-13
    In the above sample data, we have employee 123 who worked on consecutive SATURDAY and 312 who worked on consecutive weekends (9th, 10th and 16th March) but the employee 213 worked on 1st weekend and 4th weekend of the month(Archive_month). So the output should return the employees who worked on two consecutive weekends as below.
    Emp_id
    123
    312
    I have written a query to fetch all employees who worked only on a SAT or SUN which is given below, but i am not able to return the employees who worked on consecutive weekends and i need your help.
    select emp_id, count(*)
    from timesheet_archive
    where archive_month = '03/2013'
    and trim(to_char(td_date,'DAY')) in ('SATURDAY','SUNDAY')
    group by emp_id having count(*) > 1
    order by td_date desc
    Please help me with an approach in SQL or PL/SQL to generate a report of employees who worked on two consecutive weekends.
    Thanks,
    Edited by: 999145 on Apr 9, 2013 11:08 PM
    Edited by: 999145 on Apr 9, 2013 11:10 PM

    hi Manik,
    thanks for your response!!
    Please find the below create and insert scripts for your testing.
    I am also validating the output with my requirement. Thanks for your help!
    create table timesheet_archive as
    (TD_date date,
    Emp_id number(19,0),
    Effort Float,
    Archive_month varchar2);
    insert into timesheet_archive values (to_date('2-MAR-2013','dd-MON-yyyy'), 123,8,'03/2013');
    insert into timesheet_archive values (to_date('9-MAR-2013','dd-MON-yyyy'), 123,8,'03/2013');
    insert into timesheet_archive values (to_date('2-MAR-2013','dd-MON-yyyy'), 213,4,'03/2013');
    insert into timesheet_archive values (to_date('3-MAR-2013','dd-MON-yyyy'), 213,4,'03/2013');
    insert into timesheet_archive values (to_date('24-MAR-2013','dd-MON-yyyy'), 213,8,'03/2013');
    insert into timesheet_archive values (to_date('9-MAR-2013','dd-MON-yyyy'), 321,4,'03/2013');
    insert into timesheet_archive values (to_date('10-MAR-2013','dd-MON-yyyy'), 321,4,'03/2013');
    insert into timesheet_archive values (to_date('16-MAR-2013','dd-MON-yyyy'), 321,8,'03/2013');
    insert into timesheet_archive values (to_date('2-MAR-2013','dd-MON-yyyy'), 124,8,'03/2013');
    insert into timesheet_archive values (to_date('9-MAR-2013','dd-MON-yyyy'), 124,8,'03/2013');
    insert into timesheet_archive values (to_date('16-MAR-2013','dd-MON-yyyy'), 124,4,'03/2013');
    insert into timesheet_archive values (to_date('23-MAR-2013','dd-MON-yyyy'), 124,4,'03/2013');
    insert into timesheet_archive values (to_date('16-MAR-2013','dd-MON-yyyy'), 241,8,'03/2013');
    insert into timesheet_archive values (to_date('23-MAR-2013','dd-MON-yyyy'), 241,4,'03/2013');
    insert into timesheet_archive values (to_date('24-MAR-2013','dd-MON-yyyy'), 241,4,'03/2013');
    insert into timesheet_archive values (to_date('2-MAR-2013','dd-MON-yyyy'), 412,8,'03/2013');
    insert into timesheet_archive values (to_date('3-MAR-2013','dd-MON-yyyy'), 412,8,'03/2013');
    insert into timesheet_archive values (to_date('30-MAR-2013','dd-MON-yyyy'), 412,8,'03/2013');
    insert into timesheet_archive values (to_date('31-MAR-2013','dd-MON-yyyy'), 412,8,'03/2013');

  • ORDER BY IN HIERARCHIAL QUERY

    Cosider the following record set from the emp table.
    empno ename mgr
    7839 KING     
    7566 SCOTT 7839
    7566 BLAKE 7839
    7782 CLARK 7839
    If I use the following hierarchial query to populate a tree in Oracle forms
    I will get the result as shown below.
    Query
    =====
    select -1, level, ename, null, ename
    from emp
    where empno in (7839,7566,7698,7782)
    start with ename = 'KING'
    connect by mgr = prior empno;
    Result
    ======
    KING
    JONES
    BLAKE
    CLARK
    Here is my problem. Though diffrent employees can work under a manager,
    we have some internal rules that assigns an order to each employee who
    works under a manager. This helps us in identifying who should take
    charge in the absence of a manager.
    I have added one column to the emp table, in order to store the order in
    which the employee reports to the manager.
    Now the record set becomes
    empno ename mgr emp_order
    7839 KING     0
    7566 SCOTT 7839 1
    7566 BLAKE 7839 3
    7782 CLARK 7839 2
    Now I want the forms tree to be displayed as shown below.
    KING
    JONES
    CLARK
    BLAKE
    (In short, I want the records in a particular level to be displayed
    according to a pre-defined order, rather than getting them displayed
    randomly).
    Which query can I use for this purpose ?
    Please help....
    Shibu

    Hi Guys,
    Thanks a lot for your suggestions.
    It really works great in SQL Plus.
    I am familiar with Oracle Forms and I know how to use it if I want to build a tree in Forms.
    Here is my requirement. I want to build the application using Oracle Portal. I know that there is something called 'Hierarchy' available in Portal. I don't know up to what extend it gives flexibility in programatically populating the tree.
    Here is the scenario. I will use the hierarchial query with CONNECT SIBLINGS BY clause to populate the a tree which will show me employees in a department hierarchially.
    Eg:
    KING
    SCOTT
    BLAKE
    SMITH
    Now I like to show the projects assigned to each employee, which itself can be considered as another hierarchy.
    Eg of Projects hierarchy.
    Projects
    Development
    Oracle Applications
    HRMS
    Support
    Intranet Applications
    Suppose SCOTT is working in HRMS project, the tree should show as,
    KING
    SCOTT
    Projects
    Development
    Oracle Applications
    HRMS
    BLAKE
    SMITH
    I can color code the node which will distinguish between an employee and his assignments.
    Is there a way to achieve it in Oracle Portal using the 'Hierarchy' or what may be the best way to go (Applet etc...) ???
    Thanks in advance for your help.
    Shibu

  • Adding dynamic 'start with' clause in Hierarchial query in Discoverer 4i

    I have created a custom folder based upon the following hierarchial guery:
    SELECT supervisor_name, level
    FROM xxhr084_hr_emps_v
    START WITH supervisor_name = 'TEST SUPER'
    CONNECT BY prior person_id = supervisor_id
    ORDER SIBLINGS by supervisor_name
    I want the 'START WITH' value to be based upon a parameter i.e. the User enters the value of supervisor name at runtime.
    However, I can't use a parameter within the custom folder and I can't generate the 'start with' condition in my workbook.
    Anyone have a solution for populating the start with clause at run-time?
    Thanks,
    Kevin

    Can you create the custom folder without a condition on supervisor_name - i.e. without the supervisor_name = 'X' starts with clause - in the EUL, and then define the condition on the supervisor_name field within the report?
    SELECT supervisor_name, level
    FROM xxhr084_hr_emps_v
    CONNECT BY prior person_id = supervisor_id
    ORDER SIBLINGS by supervisor_name
    You can then restrict the results that the hierarchical query returns (from the custom folder) within the report, by adding a condition on supervisor_name.
    Hope that makes some sense.

  • Sort siblings of a hierarchial query in oracle8i

    Hi,
    I have a basic hierarchial query like the following:
    select *
    from users_table
    start with userid = user
    connect by manager = prior userid
    I would like to sort the employees by name under their manager. Is there an easy way to do this in Oracle8i. I cannot use the ORDER SIBLINGS BY clause until Oracle9i. Thanks for your help.

    http://www.quest-pipelines.com/pipelines/plsql/archives.htm#code16

  • Query to find employee annual salary or pay rate for a pay period (Bi-Week)

    Hi Guru's,
    need your help for finding annual salary or pay rate for pay period for an employee.
    I have below query returning some thousand line which I cant understand. Can someone correct the query please.
    SELECT ppp.proposed_salary_n salary From per_pay_proposals ppp,apps.per_all_people_f papf,apps.per_all_assignments_f paaf,apps.per_all_people_f papf1 WHERE papf.person_id = paaf.person_id AND paaf.primary_flag = 'Y' AND paaf.assignment_type = 'E' AND paaf.supervisor_id = papf1.person_id AND papf1.current_employee_flag = 'Y'AND papf.business_group_id = paaf.business_group_id AND SYSDATE BETWEEN papf.effective_start_date and papf.effective_end_date AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date AND SYSDATE BETWEEN papf1.effective_start_date AND papf1.effective_end_date AND papf.employee_number='1234';
    SALARY
    17.4346
    16.0846
    17.4346
    13.78
    13.78
    15.07
    13.78
    13.78
    13.78
    3305.59
    14.859
    SALARY
    5507.25
    2731.01
    2690.51
    13.78
    13.35
    13.35
    1960
    4192
         17
    4927
    2525.02
    SALARY
    2652
    13.35
    15.07
    2686.67
    2964
    13.78
    17.4635
    20.4981
    16.0846
    13.78
    17.4635
    SALARY
    2666.68
    13.78
    15.07
    13.78
    16.0846
    17.4635
    4353.99
    4562.51
    17.4346
    16.0846
    6727.41
    SALARY
    2780.99
         20
    17.4346
    16.0846
    2970
    2315.01
    17.4635
    2629.85
    14.5705
    5635
    17.4346
    Thanks
    Sandeep

    I used table hrpy_rgdir  to get sequence number for the given pernr, payroll area and dates.
    Using the sequence number, I am calling Function PYXX_READ_PAYROLL_RESULT to extract the payroll results.
    SELECT * INTO CORRESPONDING FIELDS OF TABLE it_hrpy_rgdir
      FROM hrpy_rgdir
      WHERE srtza = 'A'             
        AND paydt IN sopaydt
        AND abkrs IN soabkrs
        AND pernr IN sopernr.
    LOOP AT it_hrpy_rgdir.
      PERFORM get_rt USING it_hrpy_rgdir-pernr it_hrpy_rgdir-seqnr.
    ENDLOOP.
    *&      Form  get_rt
    *       text
    *      -->PERNR      text
    *      -->SEQNR      text
    FORM get_rt USING pernr seqnr.
      CLEAR: it_payroll_result.
      CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
        EXPORTING
          clusterid                    = 'RQ'
          employeenumber               = pernr
          sequencenumber               = seqnr
        CHANGING
          payroll_result               = it_payroll_result
        EXCEPTIONS
          illegal_isocode_or_clusterid = 1
          error_generating_import      = 2
          import_mismatch_error        = 3
          subpool_dir_full             = 4
          no_read_authority            = 5
          no_record_found              = 6
          versions_do_not_match        = 7
          error_reading_archive        = 8
          error_reading_relid          = 9
          OTHERS                       = 10.
    ENDFORM.                   
    For any period, the function module just returns sy-subrc = 6 [no_record_found].
    We are on Australian Payroll.  Could you please let me know what I might be missing or is there an alternative way of getting the information ?
    Thank you

  • The Query returns a JBO Sql Exeptions of Invalid number

    Here is the query which returns the Invalid number exception on a R12 environment -
    SELECT feb.entity_id,
    rel.parent_entity_id,
    fetl.entity_name,
    pfetl.entity_name parent_entity_name,
    ccytl.currency_code,
    ccytl.name AS currency_name,
    fettl.entity_type_name,
    fettl.entity_type_code,
    rel.cons_relationship_id,
    decode( fettl.entity_type_code,
    'E', to_number(''),
    decode( operassoc.parent_entity_id,
    to_number(''), rel.ownership_percent,
    to_number(''))) ownership_percent,
    ttl.treatment_name,
    cttl.curr_treatment_name,
    decode( fettl.entity_type_code,
    'O', 'Y',
    'X', 'Y',
    decode( rel.cons_relationship_id,
    '', 'Y',
    'N')) AS details_icon_displayed,
    decode( fettl.entity_type_code,
    'E', 'N',
    'O', decode(feb.entity_id,
    operassoc.child_entity_id, 'N',
    'Y'),
    'Y') AS add_entity_icon_displayed,
    decode( fettl.entity_type_code,
    'E', 'N',
    'C', decode( rel.cons_relationship_id,
    '', 'N',
    'Y'),
    decode( operassoc.parent_entity_id,
    '', 'Y',
    'N')) AS move_remove_icon_displayed,
    decode( fettl.entity_type_code,
    'E', 'N',
    'C', decode( rel.cons_relationship_id,
    '', decode( childassoc.child_entity_id,
    '', 'N',
    'Y'),
    'Y'),
    decode( operassoc.parent_entity_id,
    '', 'Y',
    'N')) AS create_update_icon_displayed,
    decode( fettl.entity_type_code,
    'E', 'N',
    'C', decode( rel.cons_relationship_id,
    '', 'N',
    'Y'),
    decode( operassoc.parent_entity_id,
    '', 'Y',
    'N')) AS update_update_icon_displayed,
    imageattr.entity_image,
    decode(imageattr.entity_image, '', 'N', 'Y') entity_image_displayed,
    rel.end_date,
    decode(rel.cons_relationship_id, :0, 'Y', 'N') blue_dot_displayed,
    decode(operassoc.parent_entity_id, '', 'Ownership', 'ParentText') ownership_switcher
    FROM FEM_ENTITIES_B feb,
    FEM_ENTITIES_TL fetl,
    FEM_ENTITIES_TL pfetl,
    GCS_ENTITY_CONS_ATTRS eca,
    FND_CURRENCIES_TL ccytl,
    FEM_ENTITIES_ATTR fetea,
    FEM_DIM_ATTRIBUTES_B fetda,
    FEM_DIM_ATTR_VERSIONS_B fet_dav,
    FEM_ENTITY_TYPES_TL fettl,
    GCS_CONS_RELATIONSHIPS rel,
    GCS_TREATMENTS_TL ttl,
    GCS_CURR_TREATMENTS_TL cttl,
    (SELECT operea.entity_id AS parent_entity_id,
    operea.dim_attribute_numeric_member AS child_entity_id
    FROM FEM_ENTITIES_ATTR operea,
    FEM_DIM_ATTRIBUTES_B operda,
    FEM_DIM_ATTR_VERSIONS_B oper_dav
    WHERE operda.attribute_varchar_label = 'OPERATING_ENTITY'
    AND operda.attribute_id = operea.attribute_id
    AND oper_dav.attribute_id = operda.attribute_id
    AND oper_dav.default_version_flag = 'Y'
    AND oper_dav.version_id = operea.version_id) operassoc,
    (SELECT operea.entity_id AS parent_entity_id,
    operea.dim_attribute_numeric_member AS child_entity_id
    FROM FEM_ENTITIES_ATTR operea,
    FEM_DIM_ATTRIBUTES_B operda,
    FEM_DIM_ATTR_VERSIONS_B oper_dav
    WHERE operda.attribute_varchar_label = 'OPERATING_ENTITY'
    AND operda.attribute_id = operea.attribute_id
    AND oper_dav.attribute_id = operda.attribute_id
    AND oper_dav.default_version_flag = 'Y'
    AND oper_dav.version_id = operea.version_id) childassoc,
    (SELECT imageea.entity_id,
    imageea.varchar_assign_value AS entity_image
    FROM FEM_ENTITIES_ATTR imageea,
    FEM_DIM_ATTRIBUTES_B imageda,
    FEM_DIM_ATTR_VERSIONS_B image_dav
    WHERE imageda.attribute_varchar_label = 'IMAGE_NAME'
    AND imageda.attribute_id = imageea.attribute_id
    AND image_dav.attribute_id = imageda.attribute_id
    AND image_dav.default_version_flag = 'Y'
    AND image_dav.version_id = imageea.version_id) imageattr
    WHERE feb.entity_id = fetl.entity_id
    AND fetl.language = userenv('LANG')
    AND eca.entity_id (+)= feb.entity_id
    AND eca.hierarchy_id (+)= :1
    AND ccytl.currency_code (+)= eca.currency_code
    AND ccytl.language (+)= userenv('LANG')
    AND fetea.entity_id = feb.entity_id
    AND fetea.attribute_id = fetda.attribute_id
    AND fetda.attribute_varchar_label = 'ENTITY_TYPE_CODE'
    AND fet_dav.attribute_id = fetda.attribute_id
    AND fet_dav.default_version_flag = 'Y'
    AND fet_dav.version_id = fetea.version_id
    AND fettl.entity_type_code = fetea.dim_attribute_varchar_member
    AND fettl.language = userenv('LANG')
    AND rel.child_entity_id (+)= feb.entity_id
    AND rel.hierarchy_id (+)= :2
    AND rel.actual_ownership_flag (+)= 'Y'
    AND pfetl.entity_id (+)= rel.parent_entity_id
    AND pfetl.language (+)= userenv('LANG')
    AND ttl.treatment_id (+)= rel.treatment_id
    AND ttl.language (+)= userenv('LANG')
    AND cttl.curr_treatment_id (+)= rel.curr_treatment_id
    AND cttl.language (+)= userenv('LANG')
    AND operassoc.child_entity_id (+)= rel.child_entity_id
    AND operassoc.parent_entity_id (+)= rel.parent_entity_id
    AND childassoc.parent_entity_id (+)= feb.entity_id
    AND imageattr.entity_id (+)= feb.entity_id
    AND (rel.start_date IS NULL OR rel.start_date <= nvl(:3, rel.start_date))
    AND (rel.end_date IS NULL OR rel.end_date >= nvl(:4, rel.end_date))
    ORDER BY decode( operassoc.parent_entity_id,
    '', decode( entity_type_code,
    'O', 2,
    'C', 3,
    'E', 4,
    999),
    1),
    entity_name
    Same query returns correct results in 11i environment.
    This query fails at the executeQueryForCollection method.
    Any ideas why?
    Thanks - Alpi
    Edited by: user581082 on Sep 17, 2009 1:16 AM

    Here is the full Error Stack -
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (SELECT     feb.entity_id,
         rel.parent_entity_id,
         fetl.entity_name,
         pfetl.entity_name parent_entity_name,
         ccytl.currency_code,
         ccytl.name AS currency_name,
         fettl.entity_type_name,
         fettl.entity_type_code,
         rel.cons_relationship_id,
         decode(     fettl.entity_type_code,
              'E', to_number(''),
              decode(     operassoc.parent_entity_id,
                   to_number(''), rel.ownership_percent,
                   to_number(''))) ownership_percent,
         ttl.treatment_name,
         cttl.curr_treatment_name,
         decode(     fettl.entity_type_code,
              'O', 'Y',
              'X', 'Y',
              decode(     rel.cons_relationship_id,
                   '', 'Y',
                   'N')) AS details_icon_displayed,
         decode(     fettl.entity_type_code,
              'E', 'N',
              'O', decode(feb.entity_id,
    operassoc.child_entity_id, 'N',
    'Y'),
              'Y') AS add_entity_icon_displayed,
         decode(     fettl.entity_type_code,
              'E', 'N',
              'C', decode(     rel.cons_relationship_id,
                        '', 'N',
                        'Y'),
              decode(     operassoc.parent_entity_id,
                   '', 'Y',
                   'N')) AS move_remove_icon_displayed,
         decode(     fettl.entity_type_code,
              'E', 'N',
              'C', decode(     rel.cons_relationship_id,
                        '', decode(     childassoc.child_entity_id,
                                  '', 'N',
                                  'Y'),
                        'Y'),
              decode(     operassoc.parent_entity_id,
                   '', 'Y',
                   'N')) AS create_update_icon_displayed,
         decode(     fettl.entity_type_code,
              'E', 'N',
              'C', decode(     rel.cons_relationship_id,
                        '', 'N',
                        'Y'),
              decode(     operassoc.parent_entity_id,
                   '', 'Y',
                   'N')) AS update_update_icon_displayed,
         imageattr.entity_image,
         decode(imageattr.entity_image, '', 'N', 'Y') entity_image_displayed,
         rel.end_date,
         decode(rel.cons_relationship_id, :0, 'Y', 'N') blue_dot_displayed,
         decode(operassoc.parent_entity_id, '', 'Ownership', 'ParentText') ownership_switcher
    FROM     FEM_ENTITIES_B feb,
         FEM_ENTITIES_TL fetl,
         FEM_ENTITIES_TL pfetl,
         GCS_ENTITY_CONS_ATTRS eca,
         FND_CURRENCIES_TL ccytl,
         FEM_ENTITIES_ATTR fetea,
         FEM_DIM_ATTRIBUTES_B fetda,
         FEM_DIM_ATTR_VERSIONS_B fet_dav,
         FEM_ENTITY_TYPES_TL fettl,
         GCS_CONS_RELATIONSHIPS rel,
         GCS_TREATMENTS_TL ttl,
         GCS_CURR_TREATMENTS_TL cttl,
         (SELECT     operea.entity_id AS parent_entity_id,
              operea.dim_attribute_numeric_member AS child_entity_id
         FROM     FEM_ENTITIES_ATTR operea,
              FEM_DIM_ATTRIBUTES_B operda,
              FEM_DIM_ATTR_VERSIONS_B oper_dav
         WHERE     operda.attribute_varchar_label = 'OPERATING_ENTITY'
         AND     operda.attribute_id = operea.attribute_id
         AND     oper_dav.attribute_id = operda.attribute_id
         AND     oper_dav.default_version_flag = 'Y'
         AND     oper_dav.version_id = operea.version_id) operassoc,
         (SELECT     operea.entity_id AS parent_entity_id,
              operea.dim_attribute_numeric_member AS child_entity_id
         FROM     FEM_ENTITIES_ATTR operea,
              FEM_DIM_ATTRIBUTES_B operda,
              FEM_DIM_ATTR_VERSIONS_B oper_dav
         WHERE     operda.attribute_varchar_label = 'OPERATING_ENTITY'
         AND     operda.attribute_id = operea.attribute_id
         AND     oper_dav.attribute_id = operda.attribute_id
         AND     oper_dav.default_version_flag = 'Y'
         AND     oper_dav.version_id = operea.version_id) childassoc,
         (SELECT     imageea.entity_id,
              imageea.varchar_assign_value AS entity_image
         FROM     FEM_ENTITIES_ATTR imageea,
              FEM_DIM_ATTRIBUTES_B imageda,
              FEM_DIM_ATTR_VERSIONS_B image_dav
         WHERE     imageda.attribute_varchar_label = 'IMAGE_NAME'
         AND     imageda.attribute_id = imageea.attribute_id
         AND     image_dav.attribute_id = imageda.attribute_id
         AND     image_dav.default_version_flag = 'Y'
         AND     image_dav.version_id = imageea.version_id) imageattr
    WHERE     feb.entity_id = fetl.entity_id
    AND     fetl.language = userenv('LANG')
    AND     eca.entity_id (+)= feb.entity_id
    AND     eca.hierarchy_id (+)= :1
    AND     ccytl.currency_code (+)= eca.currency_code
    AND     ccytl.language (+)= userenv('LANG')
    AND     fetea.entity_id = feb.entity_id
    AND     fetea.attribute_id = fetda.attribute_id
    AND     fetda.attribute_varchar_label = 'ENTITY_TYPE_CODE'
    AND     fet_dav.attribute_id = fetda.attribute_id
    AND     fet_dav.default_version_flag = 'Y'
    AND     fet_dav.version_id = fetea.version_id
    AND     fettl.entity_type_code = fetea.dim_attribute_varchar_member
    AND     fettl.language = userenv('LANG')
    AND     rel.child_entity_id (+)= feb.entity_id
    AND     rel.hierarchy_id (+)= :2
    AND rel.actual_ownership_flag (+)= 'Y'
    AND     pfetl.entity_id (+)= rel.parent_entity_id
    AND     pfetl.language (+)= userenv('LANG')
    AND     ttl.treatment_id (+)= rel.treatment_id
    AND     ttl.language (+)= userenv('LANG')
    AND     cttl.curr_treatment_id (+)= rel.curr_treatment_id
    AND     cttl.language (+)= userenv('LANG')
    AND     operassoc.child_entity_id (+)= rel.child_entity_id
    AND     operassoc.parent_entity_id (+)= rel.parent_entity_id
    AND     childassoc.parent_entity_id (+)= feb.entity_id
    AND     imageattr.entity_id (+)= feb.entity_id
    AND     (rel.start_date IS NULL OR rel.start_date <= nvl(:3, rel.start_date))
    AND     (rel.end_date IS NULL OR rel.end_date >= nvl(:4, rel.end_date))
    ORDER BY     decode(     operassoc.parent_entity_id,
                   '', decode(     entity_type_code,
                             'O', 2,
                             'C', 3,
                             'E', 4,
                             999),
                   1),
              entity_name) QRSLT WHERE PARENT_ENTITY_ID = :6
         at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:896)
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1169)
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(OAPageErrorHandler.java:1435)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2845)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1835)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:533)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:421)
         at OA.jspService(_OA.java:212)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:335)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:478)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:401)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.apps.jtf.base.session.ReleaseResFilter.doFilter(ReleaseResFilter.java:26)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.apps.fnd.security.AppsServletFilter.doFilter(AppsServletFilter.java:318)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:610)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:359)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:299)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:187)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:797)
    ## Detail 0 ##
    java.sql.SQLException: ORA-01722: invalid number
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:966)
         at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1062)
         at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:850)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3339)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3384)
         at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:857)
         at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:666)
         at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3655)
         at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
         at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(OAViewObjectImpl.java:4511)
         at oracle.apps.gcs.setup.hierarchy.server.EntitiesVOImpl.executeQueryForCollection(EntitiesVOImpl.java:106)
         at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:742)
         at oracle.jbo.server.ViewRowSetImpl.activateRowSetState(ViewRowSetImpl.java:4925)
         at oracle.jbo.server.ViewRowSetIteratorImpl.activateIteratorState(ViewRowSetIteratorImpl.java:3792)
         at oracle.jbo.server.ViewRowSetImpl.activateIteratorState(ViewRowSetImpl.java:4960)
         at oracle.jbo.server.OAJboViewObjectImpl.activateInternalRowSets(Unknown Source)
         at oracle.jbo.server.OAJboApplicationModuleImpl.activateState(Unknown Source)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.activateState(OAApplicationModuleImpl.java:3066)
         at oracle.jbo.server.ApplicationModuleImpl.doActivateState(ApplicationModuleImpl.java:7053)
         at oracle.jbo.server.ApplicationModuleImpl.doActivateAMState(ApplicationModuleImpl.java:6961)
         at oracle.jbo.server.Serializer.activate(Serializer.java:274)
         at oracle.jbo.server.DBSerializer.activateRootAM(DBSerializer.java:330)
         at oracle.jbo.server.ApplicationModuleImpl.activateFromStack(ApplicationModuleImpl.java:5768)
         at oracle.jbo.server.ApplicationModuleImpl.activateState(ApplicationModuleImpl.java:5628)
         at oracle.jbo.server.ApplicationModuleImpl.activateStateForUndo(ApplicationModuleImpl.java:7697)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.activateStateForUndo(OAApplicationModuleImpl.java:2159)
         at oracle.apps.gcs.setup.hierarchy.server.HierarchyAMImpl.activateStateForUndo(HierarchyAMImpl.java:10364)
         at oracle.apps.gcs.setup.hierarchy.webui.HierUploadCO.processFormRequest(HierUploadCO.java:89)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:815)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1189)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1027)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:993)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:848)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1027)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:993)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:848)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2841)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1835)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:533)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:421)
         at OA.jspService(_OA.java:212)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:335)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:478)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:401)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.apps.jtf.base.session.ReleaseResFilter.doFilter(ReleaseResFilter.java:26)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.apps.fnd.security.AppsServletFilter.doFilter(AppsServletFilter.java:318)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:610)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:359)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:299)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:187)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:797)
    java.sql.SQLException: ORA-01722: invalid number
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:966)
         at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1062)
         at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:850)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3339)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3384)
         at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:857)
         at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:666)
         at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3655)
         at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
         at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(OAViewObjectImpl.java:4511)
         at oracle.apps.gcs.setup.hierarchy.server.EntitiesVOImpl.executeQueryForCollection(EntitiesVOImpl.java:106)
         at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:742)
         at oracle.jbo.server.ViewRowSetImpl.activateRowSetState(ViewRowSetImpl.java:4925)
         at oracle.jbo.server.ViewRowSetIteratorImpl.activateIteratorState(ViewRowSetIteratorImpl.java:3792)
         at oracle.jbo.server.ViewRowSetImpl.activateIteratorState(ViewRowSetImpl.java:4960)
         at oracle.jbo.server.OAJboViewObjectImpl.activateInternalRowSets(Unknown Source)
         at oracle.jbo.server.OAJboApplicationModuleImpl.activateState(Unknown Source)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.activateState(OAApplicationModuleImpl.java:3066)
         at oracle.jbo.server.ApplicationModuleImpl.doActivateState(ApplicationModuleImpl.java:7053)
         at oracle.jbo.server.ApplicationModuleImpl.doActivateAMState(ApplicationModuleImpl.java:6961)
         at oracle.jbo.server.Serializer.activate(Serializer.java:274)
         at oracle.jbo.server.DBSerializer.activateRootAM(DBSerializer.java:330)
         at oracle.jbo.server.ApplicationModuleImpl.activateFromStack(ApplicationModuleImpl.java:5768)
         at oracle.jbo.server.ApplicationModuleImpl.activateState(ApplicationModuleImpl.java:5628)
         at oracle.jbo.server.ApplicationModuleImpl.activateStateForUndo(ApplicationModuleImpl.java:7697)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.activateStateForUndo(OAApplicationModuleImpl.java:2159)
         at oracle.apps.gcs.setup.hierarchy.server.HierarchyAMImpl.activateStateForUndo(HierarchyAMImpl.java:10364)
         at oracle.apps.gcs.setup.hierarchy.webui.HierUploadCO.processFormRequest(HierUploadCO.java:89)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:815)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1189)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1027)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:993)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:848)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1027)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:993)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:848)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2841)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1835)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:533)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:421)
         at OA.jspService(_OA.java:212)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:335)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:478)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:401)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.apps.jtf.base.session.ReleaseResFilter.doFilter(ReleaseResFilter.java:26)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.apps.fnd.security.AppsServletFilter.doFilter(AppsServletFilter.java:318)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:610)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:359)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:299)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:187)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:797)

  • I need Hierarchial Query

    Hi All,
    I need supervisor assignment hierarchy query(HRMS), for generating report.
    can someone help me on this??
    Any help is greately appreciated.
    Regards
    Gopi

    Hello everyone
    When i am trying to execute following query, i am getting an error like
    ORA-01473
    Cannot Have Sub Queries in Connect By Clause
    It display the hierarchy starting from our board of directors in a descending manner
    SELECT LPAD ('->', 8 * (LEVEL - 1))
    || (SELECT DISTINCT full_name
    FROM per_all_people_f
    WHERE person_id = paf.person_id
    AND PERSON_TYPE_ID '1123' -- 1123 = 'Ex-Employee'
    AND SYSDATE BETWEEN effective_start_date
    AND effective_end_date)
    TREE
    FROM per_all_assignments_f paf
    WHERE SYSDATE BETWEEN paf.effective_start_date
    AND paf.effective_end_date
    AND paf.primary_flag = 'Y'
    and paf.person_id in
    (select pf.person_id from per_all_people_f pf where pf.PERSON_TYPE_ID '1123' and paf.person_id = pf.person_id
    AND SYSDATE BETWEEN pf.effective_start_date
    AND pf.effective_end_date
    START WITH paf.person_id = (select person_id from per_all_people_f where last_name ='Board of') -- Board of Directors
    CONNECT BY PRIOR paf.person_id = paf.supervisor_id
    AND paf.primary_flag = 'Y'
    AND paf.person_id in (select person_id from per_all_people_f pf where paf.person_id = pf.person_id and pf.PERSON_TYPE_ID'1123')
    AND SYSDATE BETWEEN paf.effective_start_date
    AND paf.effective_end_date
    Could anyone help me on this??
    Regards
    Gopi

  • Multi-row sub query returns  ORA-00904 :invalid identifier error

    I am creating a report from two tables that I am not joining. I want a single line for every row in table1 that meets a date range. Table2 can contain none or many rows for each recored in table1. I want to get up to two fields from table2.
    I was using a case statement to check if there was data and then an in-line query or subquery. Once again, the idea is to have a single line on the report for each table1 record.
    I get this error with the code below. It seems the nested multi-row subquery can not see the a.cr_mas_cr_no identifier.
    ORA-00904: "a"."cr_mas_cr_no": invalid identifier
    Any help is greatly appreciated,
    Sam
    select
    a.cr_mas_cr_no "CRNO", a.cr_mas_type "TYPE", a.cr_mas_status "CR Status",
    a.cr_mas_date_logged "Logged date", a.CR_REL_REQ_APP_DATE "RTP approved",a.CR_REL_REQ_RTP_DATE "RTP Date",
    a.cr_accepted_date "Complete", a.cr_mas_submitted_by "Requester",
    select doc_user FROM crrm_cr_documents WHERE doc_cr_number =a.cr_mas_cr_no and rownum = 1 and DOC_TYPE = 'BD' ) "Bus Design",
    (select doc_user FROM crrm_cr_documents WHERE doc_cr_number = a.cr_mas_cr_no and rownum = 1 and DOC_TYPE = 'TD' ) "Tech Design",
    (select doc_user FROM crrm_cr_documents WHERE doc_cr_number = a.cr_mas_cr_no and rownum = 1 and DOC_TYPE = 'TE' ) "User acceptance test",
    case
    when (select count(appr_user) from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') > 0
    then (select appr_user from (select * from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 1)
    end
    "RTP #1",
    case
    when (select count(appr_user) from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') > 1
    then (select appr_user from (select * from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 2)
    end
    "RTP #2",
    a.CR_REL_REQ_RTP_BY "Released by",
    a.CR_ACCEPTED_BY "Post RTP User Acceptance",
    a.cr_mas_title "Title", a.cr_mas_id "ID"
    from
    crrm_crmaster a
    where
    (a.CR_REL_REQ_RTP_DATE >= :P1109_BEGDATE and (a.CR_REL_REQ_RTP_DATE <= :P1109_ENDDATE) and
    (a.cr_mas_status = 'Complete' or (a.cr_mas_status = 'Release Approved'and a.CR_REL_REQ_APP_DATE < :P1109_ENDDATE))
    Message was edited by:
    slavanaway

    Iceman,
    Thanks for the reply I will try your suggestion.
    I will try and explain why I think two subqueries (an in-line query with a subquery?) are required. I will use the creation of the column RTP #1 as the example as the RTP #2 column is only different in the rownum selected.
    Looking only at the lines that fail, here is my analysis. (If I rem out the two case lines the query runs, I just don't get two columns of data I need.) I will only examine the first case as the second is changed to extract the second approval via the rownum = 2 criteria. The first statement checks there is at least one RTP approval stored for the request and then gets the user who approved the request if the test is true.
    case when
    (select count(appr_user) from crrm_cr_approvals where appr_cr_no =a.cr_mas_cr_no and appr_type = 'RTP') > 0
    then
    The above part works fine and the correct count of approvals is returned.
    (select appr_user from (select * from crrm_cr_approvals where appr_cr_no=a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 1)
    end
    "RTP #1",
    I moved the parenthesis to the correct location. There can be multiple approvals for a given parent record. Some parent records need one, some need two approvals. If I replace
    (select appr_user from (select * from crrm_cr_approvals where appr_cr_no =a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 1)
    with
    (select appr_user from approvals where appr_cr_no =a.cr_mas_cr_no and appr_type = 'RTP' and rownum = 1)
    The correct result is returned because it returns exactly one row as rownum=1 limits the query. When rownum = 2 then the query returns null as the rownum never gets to two as the rownum column is built via the set created by the second subquery.
    The subquery builds a set of approvals for a specific "cr_no" and appr_type of "RTP". the outer query then looks at the rownum of the second query
    Here is where I got the rownum information from;
    http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
    So here is what I think is happening;
    1. Main query From and Where are processed. This should provide the "set" for the query
    2.The from subqueries for RTP #1 and RTP #2 should be able to access the a.cr_mas_cr_no field and build a set from the approvals table.
    3.The RTP #1/2 subquery (inline maybe a better description?) would then get the correct row from the from subquery.
    The error "invalid identifier" refers to the a.cr_mas_cr_no field. I assume it means it can not resolve the table alias inside the subquery.
    So maybe your grouping would help, I will try.
    Sam

  • How to find out which sub query returns more than one row

    Hi all,
    Can any one give me clue ,how to find out which sub query returns more than one row in the following query .
    /* Formatted on 2011/05/17 19:22 (Formatter Plus v4.8.8) */
    SELECT a.*, ROWNUM AS rnm
      FROM (SELECT DISTINCT '1' AS "Page View", ou.org_unit_name AS "Org",
                            prxm.mbr_idntfr AS "Beneficiary ID",
                               md.last_name
                            || ', '
                            || md.first_name AS "Beneficiary Name",
                            pci.idntfr AS "Tracking No.",
                            TO_CHAR (TRUNC (req.pa_rqst_date),
                                     'MM/dd/yyyy'
                                    ) AS "Request Date",
                            sts.status_name AS "Status",
                            req.pa_rqst_sid AS "Request #",
                            prxm.mbr_sid AS "Mbr_sid",
                            TO_CHAR
                                  (TRUNC (req.pa_revision_date),
                                   'MM/dd/yyyy'
                                  ) AS "Last Updated",
                            TO_CHAR (psd.TO_DATE, 'MM/dd/yyyy') AS "TO_DATE",
                            prxpl.prvdr_lctn_iid AS "PRVDR_LCTN_IID",
                            pd.prvdr_sid AS "PRVDR_SID", 'Y' AS "State View",
                            DECODE
                               ((SELECT DISTINCT pd.national_prvdr_idntfr
                                            FROM pa_request_x_provider_location prxplo
                                           WHERE prxplo.pa_rqst_sid =
                                                                   req.pa_rqst_sid
                                             AND prxplo.oprtnl_flag = 'A'
                                             AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                0, (SELECT prxplo.prvdr_lctn_idntfr
                                      FROM pa_request_x_provider_location prxplo
                                     WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                       AND prxplo.oprtnl_flag = 'A'
                                       AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                NULL, (SELECT prxplo.prvdr_lctn_idntfr
                                         FROM pa_request_x_provider_location prxplo
                                        WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                          AND prxplo.oprtnl_flag = 'A'
                                          AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                (SELECT DISTINCT pd.national_prvdr_idntfr
                                            FROM pa_request_x_provider_location prxplo
                                           WHERE prxplo.pa_rqst_sid =
                                                                   req.pa_rqst_sid
                                             AND prxplo.oprtnl_flag = 'A'
                                             AND prxplo.pa_prvdr_type_lkpcd = 'RR')
                               ) AS "NPI/ID",
                            DECODE
                               ((SELECT pd.org_bsns_name
                                   FROM pa_request_x_provider_location prxplo
                                  WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                    AND prxplo.oprtnl_flag = 'A'
                                    AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                NULL, (SELECT    pd.last_name
                                              || ', '
                                              || pd.first_name
                                              || ' '
                                              || pd.middle_name
                                         FROM pa_request_x_provider_location prxplo
                                        WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                          AND prxplo.oprtnl_flag = 'A'
                                          AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                (SELECT pd.org_bsns_name
                                   FROM pa_request_x_provider_location prxplo
                                  WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                    AND prxplo.oprtnl_flag = 'A'
                                    AND prxplo.pa_prvdr_type_lkpcd = 'RR')
                               ) AS "Prvdr Name",
                            TO_CHAR (psd.from_date,
                                     'MM/dd/yyyy'
                                    ) AS "Srvc From Date",
                            TO_CHAR (req.validity_start_date,
                                     'MM/DD/YYYY'
                                    ) AS "Due Date",
                            (fn_get_busniess_days (TRUNC (req.validity_start_date))
                            ) AS "Days<br>Left",
                            req.pa_mode_type_lkpcd AS "Source",
                            TO_CHAR (TRUNC (wmdtl.rtng_date),
                                     'MM/dd/yyyy'
                                    ) AS "Assigned On",
                            NVL (wmdtl.assigned_to_user_name,
                                 'Not Assigned'
                                ) AS "Assigned To",
                            req.org_unit_sid AS "OrgUnitSid",
                            TO_CHAR
                                 (wmdtl.modified_date,
                                  'MM/dd/yyyy hh24:mi:ss'
                                 ) AS "WTRD_MODIFIED_DATE",
                            TO_CHAR (wmdtl.rtng_date,
                                     'MM/dd/yyyy'
                                    ) AS "WTRD_RTNG_DATE",
                            req.status_cid AS "PA_STATUS_CID",
                            TO_CHAR (req.modified_date,
                                     'MM/dd/yyyy'
                                    ) AS "PA_REQ_MODIFIED_DATE",
                            prs.state_pa_srvc_type_code
                                                     AS "STATE_PA_SRVC_TYPE_CODE",
                            wmdtl.wm_pa_task_rtng_dtl_sid
                                                        AS "WM_TASK_RTNG_DTL_SID",
                            wmdtl.assigned_to_user_acct_sid
                                              AS "WTRD_Assigned_to_user_acct_sid",
                            (fn_get_busniess_days (TRUNC (req.validity_start_date))
                            ) AS "Days<br>LeftSort",
                            wmdtl.assigned_to_org_unit_sid
                                                  AS "WTRD_Assigned_to_OrgUntSid",
                            DECODE
                               ((SELECT COUNT (*)
                                   FROM pa_request_status prs
                                  WHERE prs.pa_rqst_sid = req.pa_rqst_sid
                                    AND prs.status_cid = 5
                                    AND prs.oprtnl_flag = 'I'),
                                0, 'N',
                                'Y'
                               ) AS "SHOW_UTILIZATION"
                       FROM   pa_request req,
                             pa_certification_identifier pci,
                             status sts,
                             pa_request_x_member prxm,
                             wm_pa_task_routing_detail wmdtl,
                             pa_service_date psd,
                             org_unit ou,
                             pa_request_service prs,
                             pa_request_x_provider_location prxpl,
                             provider_location pl,
                             provider_detail pd,
                             provider p,
                             mbr_dmgrphc md
                      WHERE req.oprtnl_flag = 'A'
                        AND req.status_cid NOT IN
                                     (20, 30, 70, 25, 80, 96, 85, 5, 97, 98, 101)
                        AND req.org_unit_sid IN
                               (3057, 3142, 3058, 3143, 3059, 3144, 3060, 3145,
                                3061, 3146, 3062, 3147, 3063, 3148, 3064, 3149,
                                3065, 3150, 3066, 3151, 3067, 3152, 3068, 3153,
                                3069, 3154, 3070, 3155, 3071, 3156, 3072, 3157,
                                3073, 3158, 3074, 3159, 3075, 3160, 3076, 3161,
                                3077, 3162, 3078, 3163, 3079, 3164, 3080, 3165,
                                3081, 3166, 3082, 3167, 3083, 3168, 3084, 3169,
                                3085, 3170, 3086, 3171, 3087, 3172, 3088, 3173,
                                3089, 3174, 3090, 3175, 3091, 3176, 3092, 3177,
                                3093, 3178, 3094, 3179, 3095, 3180, 3096, 3181,
                                3097, 3182, 3098, 3183, 3099, 3184, 3100, 3185,
                                3101, 3186, 3102, 3187, 3103, 3003, 75000104,
                                75000108, 2006, 75000103, 75000102, 75000113,
                                75000111, 75000109, 2001, 2009, 75000105,
                                75000107, 2004, 2010, 2013, 2014, 2005, 2011,
                                75000112, 2002, 1001, 2012, 75000106, 2007,
                                75000101, 2003, 75000110, 2008, 3001, 3002, 3019,
                                3104, 3020, 3105, 3021, 3106, 3022, 3107, 3023,
                                3108, 3024, 3109, 3025, 3110, 3026, 3111, 3027,
                                3112, 3028, 3113, 3029, 3114, 3030, 3115, 3031,
                                3116, 3032, 3117, 3033, 3118, 3034, 3119, 3035,
                                3120, 3036, 3121, 3037, 3122, 3038, 3123, 3039,
                                3124, 3040, 3125, 3041, 3126, 3042, 3127, 3043,
                                3128, 3044, 3129, 3045, 3130, 3046, 3131, 3047,
                                3132, 3048, 3133, 3049, 3134, 3050, 3135, 3051,
                                3136, 3052, 3137, 3053, 3138, 3054, 3139, 3055,
                                3140, 3056, 3141)
                        AND req.pa_rqst_sid = prs.pa_rqst_sid
                        AND prs.oprtnl_flag = 'A'
                        AND prs.pa_rqst_srvc_sid = psd.pa_rqst_srvc_sid
                        AND psd.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = pci.pa_rqst_sid
                        AND pci.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = prxm.pa_rqst_sid
                        AND prxm.oprtnl_flag = 'A'
                        AND md.oprtnl_flag = 'A'
                        AND md.status_cid = 2
                        AND TRUNC (SYSDATE) BETWEEN md.from_date AND md.TO_DATE
                        AND prxm.mbr_sid = md.mbr_sid
                        AND ou.org_unit_sid = req.org_unit_sid
                        AND ou.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND prxm.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND pci.pa_rqst_sid = prxm.pa_rqst_sid
                        AND pci.pa_rqst_sid = wmdtl.subsystem_task_sid
                        AND pci.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND prxpl.pa_prvdr_type_lkpcd = 'RR'
                        AND prxpl.oprtnl_flag = 'A'
                        AND req.status_cid = sts.status_cid
                        AND sts.status_type_cid = 3
                        AND sts.oprtnl_flag = 'A'
                        AND prxpl.prvdr_lctn_iid = pl.prvdr_lctn_iid
                        AND p.prvdr_sid = pd.prvdr_sid
                        AND p.prvdr_sid = pl.prvdr_sid
                        AND pd.oprtnl_flag = 'A'
                        AND pd.status_cid = 2
                        AND TRUNC (SYSDATE) BETWEEN pd.from_date AND pd.TO_DATE
                        AND wmdtl.subsystem_task_sid = req.pa_rqst_sid
                        AND wmdtl.subsystem_lkpcd = 'PA'
                        AND wmdtl.oprtnl_flag = 'A'
                        AND req.pa_rqst_date > (SYSDATE - 365)
                                       ORDER BY TO_DATE ("Request Date", 'MM/dd/yyyy hh24:mi:ss') DESC,
                            "Beneficiary Name" ASC) a
    WHERE ROWNUM < 102;regards,
    P Prakash
    Edited by: BluShadow on 17-May-2011 15:01
    added {noformat}{noformat} tags around the code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    833560 wrote:
    Can any one give me clue ,how to find out which sub query returns more than one row in the following query .This is why smaller, simpler queries are easier to work with than huge ones - when something like this goes wrong smaller queries are much eaiser to debug. Unfortunately using smaller, easier-to-work with queries is not always an option
    Ganesh is right - you will have to dissect the big query bit by bit until you find the offending subquery. If there is another way I would like to find out about it too.
    The easiest way to do this is probably to use block comments to isolate parts of the query bit by bit until you find the offending part. If you carefully examine the subqueries you might be able to figure out which one is returning multiple rows without commenting everything
    Good luck!

  • CONNECT BY QUERY returns different count of rown in 10g resp. 11g databases

    Folks,
    I just spot a bellow issue in our databases.
    1.) 10g database:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.1.0.5.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select * from global_name;
    SQL> SELECT ROWNUM
      2    FROM   dual
      3  CONNECT BY ROWNUM <= 2;
        ROWNUM
             1
             2
             3
    SQL> 2. 11g database
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select * from global_name;
    SQL> SELECT ROWNUM
      2    FROM   dual
      3    CONNECT BY ROWNUM <= 2;
        ROWNUM
             1
             2
    SQL> As you can see in 10g above query returns 3 records, in 11g only 2.
    Why it's like that? Can it be somehow set, to produce the same output?
    Many thanks,
    Tomas

    I get correct rows on both database version !
    Oracle Versions
    10g 10.2.0.1.0
    11g 11.1.0.6.0
    SQL> select rownum from dual connect by rownum <= 2;
        ROWNUM
             1
             2
    SQL> select * from v$version ;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> select rownum from dual connect by rownum <= 2;
        ROWNUM
             1
             2
    SQL> select * from v$version ;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production

  • Hierarchial Query 3 Levels

    Hello All,
    I have searched OTN and AskTom and saw many articles on hierarchial query but I just cannot seem to figure out how to apply it to my situation. Based on what I have read I do not believe CUBE or ROLLUP is the answer for this (maybe wrong..).
    This data is only a small part of a much larger query used for auditing purposes, so i would need to incorporate the solution for this into the larger query.
    Part of my problem is how to actual present this data in a format that would make sense to the end user, when included in a tabular (Excel) report.
    I am trying to devise a way to verify that monthly payment is received for each product. In this case, some of the products are "created" under another product and then billed under a 3rd product.
    To explain the table
    Prod_1 - list all products
    Prod_2 - lists only those products that are the parent of an item in the Prod_1 column.
    Prod_3 - shows there is a relationship between an item in Prod_1 that is not in Prod_2.
    There may be items in Prod_1 that have no relationship to Prod_2 or Prod_3 are those are just billed or *not getting billed BAD*
    There are other cases where there is a item in Prod_2 that is the parent of one or more items in Prod_1 but not related to Prod_3 and those are billed.
    There are other cases where there is a item in Prod_2 that is the parent of one or more items in Prod_1 but not related to Prod_3 and *not getting billed BAD*
    For example:
    +1-abcd-efgh, 3-qrst-uvwx and 5-ghij-klmn+ under Prod_1 is created under Prod_2 +1234-2f-maker-taker+ but billed under Prod_3 +87-test-789101+ at $139.11 MONTH_CHARGE.
    CREATE TABLE PRODT ( design_id VARCHAR2(50), Prod_1 VARCHAR2(50), Prod_2 VARCHAR2(50), Prod_3 VARCHAR2(50), Month_Charge NUMBER );
    INSERT INTO PRODT VALUES ( '8568','1-abcd-efgh', '1234-2f-maker-taker','', 0 );
    INSERT INTO PRODT VALUES ( '8569','2-ijkl-mnop', '5678-3f-maker-taker','', 0 );
    INSERT INTO PRODT VALUES ( '8570','3-qrst-uvwx', '1234-2f-maker-taker','', 0 );
    INSERT INTO PRODT VALUES ( '8571','4-yzab-cdef', '5678-3f-maker-taker','', 0 );
    INSERT INTO PRODT VALUES ( '8572','5-ghij-klmn', '1234-2f-maker-taker','', 0 );
    INSERT INTO PRODT VALUES ( '9421','1234-2f-maker-taker','','87-test-789101', 0 );
    INSERT INTO PRODT VALUES ( '9588','5678-3f-maker-taker','','88-test-123456', 0 );
    INSERT INTO PRODT VALUES ( '2531','87-test-789101', '', '1234-2f-maker-taker',139.11 );
    INSERT INTO PRODT VALUES ( '2532','88-test-123456', '','5678-3f-maker-taker', 159.45 );
    INSERT INTO PRODT VALUES ( '4531','76-test-101568', '', '',145.00 );
    INSERT INTO PRODT VALUES ( '3528','6-abcd-efgh', '2234-1f-maker-taker','', 0 );
    INSERT INTO PRODT VALUES ( '3529','7-ijkl-mnop', '2234-1f-maker-taker','', 0 );
    INSERT INTO PRODT VALUES ( '6261','2234-1f-maker-taker','','', 0 );
    COMMIT; Desired Result:
    Honestly - I am not sure of the best way to present it - definetly open for suggestions!
    The table shows there is a relationship by Product Number, but the table does not make it clear that as in the example above that
    all of the underlying products are being billed under +87-test-789101+ at $139.11 per month.
    I must still show all of the Prod columns - so for my understanding Cube or Rollup is not a good fit(?).
    That is what I am trying to accomplish - in other words I am getting paid for everything or not?
    In my mind I see it something like this perhaps:
    DESIGN_ID             PROD_1                    PROD_2                       PROD_3                    MONTH_CHARGE                BILL_INDICATOR
    8569                    2-ijkl-mnop                 5678-3f-maker-taker         NULL                                 0                         ? (Not sure how to indicate
    8571                    4-yzab-cdef                5678-3f-maker-taker         NULL                                 0                         what should be displayed
    9588                    5678-3f-maker-taker    NULL                           88-test-123456                     0                         in this new column to make
    2532                    88-test-123456          NULL                            5678-3f-maker-taker           159.45                    the Audit process simple *Help Needed*)Thanks for looking!
    G
    Edited by: GMoney on Aug 22, 2012 12:54 PM
    Edited by: GMoney on Aug 22, 2012 12:57 PM

    Frank,
    I was hoping you would cross paths with this post.
    I am building on a TOP N query you helped me with in another post.
    As I mentioned in my an initial post, I have products that may be in a hierarchical order (or stand alone) could be billed as primary or with secondary or tertiary products that are billed under the primary. Meaning the primary would have a dollar figure associated, and may or may not have secondary or tertiary products related to it.
    To explain the table
    Prod_1 - list all products
    Prod_2 - lists only those products that are the parent of an item in the Prod_1 column.
    Prod_3 - shows there is a relationship between an item in Prod_1 that is not in Prod_2.
    There may be items in Prod_1 that have no relationship to Prod_2 or Prod_3 are those are just billed or not getting billed BAD
    There are other cases where there is a item in Prod_2 that is the parent of one or more items in Prod_1 but not related to Prod_3 and those are billed.
    There are other cases where there is a item in Prod_2 that is the parent of one or more items in Prod_1 but not related to Prod_3 and not getting billed BAD
    My business requirement is to present all of the results from the initial query as well as adding in the dollar figures from an addition query against another financial table. I need to be able to make it perfectly clear to an end user auditor that each and every product is being billed, and clearly identify the secondary or tertiary items if there are any that fall under that primary product.
    My real hung up here is the presentation of the data. I can easily see the correlation between them but it is not likely an end user would.
    DESIGN_ID             PROD_1                    PROD_2                       PROD_3                 MONTH_CHARGE       BILL_INDICATOR
    8569                    2-ijkl-mnop                 5678-3f-maker-taker         NULL                             0              ? (Not sure how to indicate
    8571                    4-yzab-cdef                5678-3f-maker-taker         NULL                             0                 what should be displayed
    9588                    5678-3f-maker-taker    NULL                           88-test-123456                 0                 in this new column to make
    2532                    88-test-123456          NULL                            5678-3f-maker-taker      159.45 ;          the Audit process simple *Help Needed*) Thanks for looking,
    Greg

  • Hierarchy Query

    Hi All..
    I have a hierarchy query with description as below
    SQL> desc manager_entity;
    Name                                      Null?    Type
    MANAGER_ENTITY_ID               NOT NULL NUMBER
    MANAGER_ENTITY_TYPE_ID      NOT NULL NUMBER
    MANAGER_ENTITY_PARENT_ID                  NUMBER
    CREATE_USER                          NOT NULL  VARCHAR2(50)
    CREATE_DATETIME                    NOT NULL DATE
    LAST_UPDATE_USER                 NOT NULL  VARCHAR2(50)
    LAST_UPDATE_DATETIME           NOT NULL DATE
    MANAGER_ENTITY_LINK_ID       NOT NULL  NUMBERI got the correct relation between the parent and child using the below query
    select  me.manager_entity_id
    ,      me.manager_entity_type_id
    ,      me.manager_entity_parent_id
    ,      me.manager_entity_link_id
    ,      level
    from manager_entity me
    start with me.manager_entity_id=:p_id
    connect by prior me.manager_entity_id=me.manager_entity_parent_idWhen I try to join this table with other 3 tables I’m unable to retrieve data. Description of the other 3 tables
    SQL> desc manager_product;
    Name                                      Null?    Type
    MANAGER_PRODUCT_ID                        NOT NULL NUMBER
    MANAGER_PRODUCT_NAME                      NOT NULL VARCHAR2(50)
    MANAGER_ROOF_ID                           NOT NULL NUMBER
    ACT_STRATEGY                                       VARCHAR2(50)
    ACT_SUB_STRATEGY                                   VARCHAR2(50)
    ACT_DATE_ENTERED                                   DATE
    ACT_INCEPTION_DATE                                 DATE
    ACT_PEER_GROUP                                     VARCHAR2(50)
    BACK_OFFICE_RISK_ID                                NUMBER
    AREA_ID                                            NUMBER
    ACT_CREATE_DATE                                    DATE
    PROCESS_STOP_DATE                                  DATE
    TARGET_COMPLETION_DATE                             DATE
    REVISIT_DATE                                       DATE
    CREATE_USER                                        VARCHAR2(50)
    CREATE_DATETIME                                    DATE
    LAST_UPDATE_USER                                   VARCHAR2(50)
    LAST_UPDATE_DATETIME                               DATE
    SQL> desc manager_roof;
    Name                                      Null?    Type
    MANAGER_ROOF_ID                           NOT NULL NUMBER
    MANAGER_ROOF_NAME                         NOT NULL VARCHAR2(50)
    ROOF_COMPANY_ID                           NOT NULL NUMBER
    CREATE_USER                                        VARCHAR2(50)
    CREATE_DATETIME                                    DATE
    LAST_UPDATE_USER                                   VARCHAR2(50)
    LAST_UPDATE_DATETIME                               DATE
    SQL> desc investment_vehicle;
    Name                                      Null?    Type
    INVESTMENT_VEHICLE_ID                     NOT NULL NUMBER
    INVESTMENT_VEHICLE_NAME                   NOT NULL VARCHAR2(255)
    INVESTMENT_VEHICLE_ARRT_NAME                       VARCHAR2(255)
    INVESTIER_SYSID                                    NUMBER
    INVESTIER_ID                                       VARCHAR2(100)
    MANAGER_PRODUCT_ID                                 NUMBER
    TRADING_STRUCTURE_TYPE_ID                          NUMBER
    LEGAL_DESIGNATION_ID                               NUMBER
    ADDITIONAL_INVEST_FORM_TYPE_ID                     NUMBER
    INVESTMENT_VEH_CLASS_TYPE_ID                       NUMBER
    ERISA_PLAN_ASSET_CATEGORY_ID                       NUMBER
    SIDE_LETTER_FLAG                                   CHAR(1)
    INCEPTION_DATE                                     DATE
    ALLOW_ERISA_FLAG                                   CHAR(1)
    ALLOW_PLAN_ASSET_FLAG                              CHAR(1)
    ALLOW_US_TAXABLE_INVESTOR_FLAG                     CHAR(1)
    ALLOW_OFFSHORE_INVESTOR_FLAG                       CHAR(1)
    SUB_DOC_DEADLINE                                   NUMBER
    WIRE_DEADLINE                                      NUMBER
    DOMICILE_COUNTRY_ID                                NUMBER
    CREATE_USER                                        VARCHAR2(50)
    CREATE_DATETIME                                    DATE
    LAST_UPDATE_USER                                   VARCHAR2(50)
    LAST_UPDATE_DATETIME                               DATE
    PERTRAC_DATA_VENDOR_ID                             VARCHAR2(255)
    PERTRAC_DATA_VENDOR_NAME                           VARCHAR2(255)
    FTS_NAME                                           VARCHAR2(255)
    MATLAB_MANAGER_NAME                                VARCHAR2(255)
    ACT_CO_FUND_NAME                                   VARCHAR2(255)
    ACT_INVESTMENT_VEHICLE_NAME                        VARCHAR2(255)
    SIDE_POCKET_PCT                                    NUMBER
    MAX_ILLIQUID_PCT                                   NUMBER
    CONTRIBUTION_OPENING_ID                            NUMBER
    MANAGEMENT_FEE_PCT                                 NUMBER
    INCENTIVE_FEE_PCT                                  NUMBER
    SIDE_POCKET_NOTE                                   VARCHAR2(4000)
    FTS_ID                                             NUMBERI was trying to join the other 3 tables with the main query as below..
    select  me.manager_entity_id
    ,      me.manager_entity_type_id
    ,      me.manager_entity_parent_id
    ,      me.manager_entity_link_id
    ,      level
    from manager_entity me
    ,    manager_roof mr
    ,    manager_product mp
    ,    investment_vehicle iv
    where me.manager_entity_link_id= mr.manager_roof_id
    and   mr.manager_roof_id= mp.manager_roof_id
    and   mp.manager_product_id= iv.manager_product_id
    start with me.manager_entity_id=:p_id
    connect by prior me.manager_entity_id=me.manager_entity_parent_idHere manager_entity_link_id of manager_entity table represents(or has) the primary key of all the other 3 table..like
    Enter value for p_id: 1
    old   7: start with me.manager_entity_id=&p_id
    new   7: start with me.manager_entity_id=1
    MANAGER_ENTITY_ID MANAGER_ENTITY_TYPE_ID MANAGER_ENTITY_PARENT_ID
    MANAGER_ENTITY_LINK_ID      LEVEL
                    1                   1008
                     14793          1
                  263                   1009                        1
                     19695          2
                  803                   1010                      263
                   7031783          3
    MANAGER_ENTITY_ID MANAGER_ENTITY_TYPE_ID MANAGER_ENTITY_PARENT_ID
    MANAGER_ENTITY_LINK_ID      LEVEL
                  804                   1010                      263
                   7031782          3
                  805                   1010                      263
                   7031781          3The above is the output for the hierarchy query
    Here the MANAGER_ENTITY_LINK_ID has values (14793, 19695, 7031783 , 7031782 , 7031781)
    Where 14793 is the manager_roof_id in manager_roof_table
    19695 is the manager_product_id in the manager_product table
    7031783 , 7031782 , 7031781 are the investment_vehicle_id’s in the investment_vehicle table…
    In the output I need to retrieve manager_roof_name, manager_product_name, investment_vehicle_name..
    Thanks in advance
    HTH
    Edited by: user10280715 on Dec 3, 2008 11:55 AM

    The reason result show as no rows selected is your first insert. If fails since column list has 3 columns while values list has 4 values. You probably missed "ORA-00913: too many values" error:
    SQL> drop table manager_entity
      2  /
    Table dropped.
    SQL> create table manager_entity(manager_entity_id number,manager_entity_type_id number,manager_entity_parent_id number,manager_entity_link_id number)
      2  /
    Table created.
    SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_link_id)
      2  values(1,1008,null,14793)
      3  /
    insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_link_id)
    ERROR at line 1:
    ORA-00913: too many values
    SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
      2  values(263, 1009, 1, 19695)
      3  /
    1 row created.
    SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
      2  values(803, 1010, 263, 7031783)
      3  /
    1 row created.
    SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
      2  values(804, 1010, 263, 7031782)
      3  /
    1 row created.
    SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
      2  values(805, 1010, 263, 7031781)
      3  /
    1 row created.
    SQL> drop table manager_roof
      2  /
    Table dropped.
    SQL> create table manager_roof(manager_roof_id number,manager_roof_name varchar2(20))
      2  /
    Table created.
    SQL> insert into manager_roof(manager_roof_id,manager_roof_name)
      2  values(14793,'roof')
      3  /
    1 row created.
    SQL> drop table manager_product
      2  /
    Table dropped.
    SQL> create table manager_product(manager_product_id number,manager_product_name varchar2(20),manager_roof_id number)
      2  /
    Table created.
    SQL> Insert into manager_product(manager_product_id,manager_product_name,manager_roof_id)
      2  Values(19695,'product1', 14793)
      3  /
    1 row created.
    SQL> drop table investment_vehicle
      2  /
    Table dropped.
    SQL> create table investment_vehicle(investment_vehicle_id number,manager_product_id number,investment_vehicle_name  varchar2(20))
      2  /
    Table created.
    SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
      2  Values(7031781,19695,'inv1')
      3  /
    1 row created.
    SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
      2  Values(7031782,19695,'inv3')
      3  /
    1 row created.
    SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
      2  Values(7031783,19695,'inv3')
      3  /
    1 row created.
    SQL> COMMIT
      2  /
    Commit complete.
    SQL>
    SQL> select  me.manager_entity_id
      2  ,      me.manager_entity_type_id
      3  ,      me.manager_entity_parent_id
      4  ,      me.manager_entity_link_id
      5  ,      level
      6  from manager_entity me
      7  start with me.manager_entity_id=&p_id
      8  connect by prior me.manager_entity_id=me.manager_entity_parent_id
      9 
    SQL> /
    Enter value for p_id: 1
    old   7: start with me.manager_entity_id=&p_id
    new   7: start with me.manager_entity_id=1
    no rows selectedAs soon as you fix the error:
    SQL> drop table manager_entity
      2  /
    Table dropped.
    SQL> create table manager_entity(manager_entity_id number,manager_entity_type_id number,manager_entity_parent_id number,manager_entity_link_id number)
      2  /
    Table created.
    SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
      2  values(1,1008,null,14793)
      3  /
    1 row created.
    SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
      2  values(263, 1009, 1, 19695)
      3  /
    1 row created.
    SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
      2  values(803, 1010, 263, 7031783)
      3  /
    1 row created.
    SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
      2  values(804, 1010, 263, 7031782)
      3  /
    1 row created.
    SQL> insert into manager_entity(manager_entity_id,manager_entity_type_id,manager_entity_parent_id,manager_entity_link_id)
      2  values(805, 1010, 263, 7031781)
      3  /
    1 row created.
    SQL> drop table manager_roof
      2  /
    Table dropped.
    SQL> create table manager_roof(manager_roof_id number,manager_roof_name varchar2(20))
      2  /
    Table created.
    SQL> insert into manager_roof(manager_roof_id,manager_roof_name)
      2  values(14793,'roof')
      3  /
    1 row created.
    SQL> drop table manager_product
      2  /
    Table dropped.
    SQL> create table manager_product(manager_product_id number,manager_product_name varchar2(20),manager_roof_id number)
      2  /
    Table created.
    SQL> Insert into manager_product(manager_product_id,manager_product_name,manager_roof_id)
      2  Values(19695,'product1', 14793)
      3  /
    1 row created.
    SQL> drop table investment_vehicle
      2  /
    Table dropped.
    SQL> create table investment_vehicle(investment_vehicle_id number,manager_product_id number,investment_vehicle_name  varchar2(20))
      2  /
    Table created.
    SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
      2  Values(7031781,19695,'inv1')
      3  /
    1 row created.
    SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
      2  Values(7031782,19695,'inv3')
      3  /
    1 row created.
    SQL> Insert into investment_vehicle(investment_vehicle_id,manager_product_id,investment_vehicle_name)
      2  Values(7031783,19695,'inv3')
      3  /
    1 row created.
    SQL> COMMIT
      2  /
    Commit complete.
    SQL>
    SQL> select  me.manager_entity_id
      2  ,      me.manager_entity_type_id
      3  ,      me.manager_entity_parent_id
      4  ,      me.manager_entity_link_id
      5  ,      level
      6  from manager_entity me
      7  start with me.manager_entity_id=&p_id
      8  connect by prior me.manager_entity_id=me.manager_entity_parent_id
      9 
    SQL> /
    Enter value for p_id: 1
    old   7: start with me.manager_entity_id=&p_id
    new   7: start with me.manager_entity_id=1
    MANAGER_ENTITY_ID MANAGER_ENTITY_TYPE_ID MANAGER_ENTITY_PARENT_ID MANAGER_ENTITY_LINK_ID      LEVEL
                    1                   1008                                           14793          1
                  263                   1009                        1                  19695          2
                  803                   1010                      263                7031783          3
                  804                   1010                      263                7031782          3
                  805                   1010                      263                7031781          3
    SQL> SY.

  • XML attributes makes my query return no rows

    Hello everyone,
    I've an odd problem.
    I'm querying some XML, but the attributes in one of the tags make my query return no rows; if I remove the attributes, then the query works as expected.
    The XML is below; it's the attributes in the Report tag that cause the issues:
    <result errorCode="0">
         <return>
              <Report
                   xsi:schemaLocation="Items_x0020_status_x0020_information http://******-****/ReportServer?%2FReports%2FContent%20Producer%20Reports%2FItems%20status%20information&amp;rs%3AFormat=xml&amp;rc%3ASchema=True"
                   Name="Items status information" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns="Items_x0020_status_x0020_information">
                   <Tablix1>
                        <Details_Collection>
                             <Details ItemId="914P7" Username="test" user_role="IT"
                                  first_name="Barry" last_name="Donovan" organisation=""
                                  content_format="On_Screen" modified_date="26/05/2011 13:16:49"
                                  item_status="Draft" status_date="" component_name="" demand="" />
                        </Details_Collection>
                   </Tablix1>
              </Report>
         </return>
    </result>My query is:
         select
                a.item_id
               ,a.username
               ,a.user_role
               ,a.first_name
               ,a.last_name
               ,a.supplier_id
               ,a.format
               ,a.modified_date
               ,a.item_status
               ,a.completion_date
               ,a.component_code
             from   dual
                   ,xmltable
                    ('/result/return/Report/Tablix1/Details_Collection/Details'
                       passing p_xml
                       columns
                          item_id         varchar2(1000) path '@ItemId'
                         ,username        varchar2(1000) path '@Username'
                         ,user_role       varchar2(1000) path '@user_role'
                         ,first_name      varchar2(1000) path '@first_name'
                         ,last_name       varchar2(1000) path '@last_name'
                         ,supplier_id     varchar2(1000) path '@organisation'
                         ,format          varchar2(1000) path '@content_format'
                         ,modified_date   varchar2(1000) path '@modified_date'
                         ,item_status     varchar2(1000) path '@item_status'
                         ,completion_date varchar2(1000) path '@status_date'
                         ,component_code  varchar2(1000) path '@demand'
                    ) a;I've tried stripping out the attributes in the tag, which does work, but some of the XML I'm expecting back may be quite large (many records), so that caused issues in itself. I'd rather deal with it and not mess with the XML itself if possible.
    Any help would be hugely appreciated!
    Thank you very much in advance.
    Robin
    Edited by: User_resU on Apr 12, 2012 2:50 PM

    Example:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select xmltype('<result errorCode="0">
      2     <return>
      3             <Report
      4                     xsi:schemaLocation="Items_x0020_status_x0020_information http://******-****/ReportServer?%2FReports%2FContent%20Producer%20Reports%2FItems%20status%20information&amp;rs%3AFormat=xml&amp;rc%3ASchema=True"
      5                     Name="Items status information" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      6                     xmlns="Items_x0020_status_x0020_information">
      7                     <Tablix1>
      8                             <Details_Collection>
      9                                     <Details ItemId="914P7" Username="test" user_role="IT"
    10                                             first_name="Barry" last_name="Donovan" organisation=""
    11                                             content_format="On_Screen" modified_date="26/05/2011 13:16:49"
    12                                             item_status="Draft" status_date="" component_name="" demand="" />
    13                             </Details_Collection>
    14                     </Tablix1>
    15             </Report>
    16     </return>
    17  </result>') as xml from dual)
    18  --
    19  -- end of test data
    20  --
    21       select
    22              a.item_id
    23             ,a.username
    24             ,a.user_role
    25             ,a.first_name
    26             ,a.last_name
    27             ,a.supplier_id
    28             ,a.format
    29             ,a.modified_date
    30             ,a.item_status
    31             ,a.completion_date
    32             ,a.component_code
    33           from   t
    34                 ,xmltable
    35                  (xmlnamespaces('Items_x0020_status_x0020_information' as "x0"),
    36                   '//x0:Report/x0:Tablix1/x0:Details_Collection/x0:Details'
    37                     passing xml
    38                     columns
    39                        item_id         varchar2(1000) path '@ItemId'
    40                       ,username        varchar2(1000) path '@Username'
    41                       ,user_role       varchar2(1000) path '@user_role'
    42                       ,first_name      varchar2(1000) path '@first_name'
    43                       ,last_name       varchar2(1000) path '@last_name'
    44                       ,supplier_id     varchar2(1000) path '@organisation'
    45                       ,format          varchar2(1000) path '@content_format'
    46                       ,modified_date   varchar2(1000) path '@modified_date'
    47                       ,item_status     varchar2(1000) path '@item_status'
    48                       ,completion_date varchar2(1000) path '@status_date'
    49                       ,component_code  varchar2(1000) path '@demand'
    50*                 ) a
    SQL> /
    ITEM_ID
    USERNAME
    USER_ROLE
    FIRST_NAME
    LAST_NAME
    SUPPLIER_ID
    FORMAT
    MODIFIED_DATE
    ITEM_STATUS
    COMPLETION_DATE
    COMPONENT_CODE
    914P7
    test
    IT
    Barry
    Donovan
    On_Screen
    26/05/2011 13:16:49
    Draft

Maybe you are looking for

  • Error on Startup MiniWAS 6.2 - DBIF_RSQL_INVALID_REQUEST

    Dear All, We are facing a strange issue when trying to call into the newly installed MiniWAS 6.2 system. We have installed SAP MiniWAS 6.2 on Windows XP. The laptop is not connected to any network. We have configured MS loopback adapter as well. The

  • Possible to get Apple TV for older TV

    I'm hoping there is a way (and if so, how) to hook up any generation of Apple TV to this television http://www.cnet.com/products/samsung-hln567w/specs/ If so, PLEASE respond ASAP! Thanks so much in advance for any help, Christian

  • Case when null statement

    Afternoon Folks, The line highlighted in Bold is where I have the issue. I want it to pick up NULL or Blanks in the method type has well as types E,G,T. I've tried NULL is the statement, "", and '' put none of these work. What am I doing wrong? I'm u

  • HT5429 How to create map on PC or create a map?

    Hello, As we know, the MAPS app is absolutely horrendous.  Not only can I no longer use my app walkrunjog, I can't even create a walking map!  Is there an online version where I can view and create a map to be sent to my iphone?  I can't even tell yo

  • LD_LIBRARY_PATH pointing to i386 libraries after upgrade to R12.1 from 11i

    Hi, Recently we have upgraded our EBS 11.5.10.2 to R12.1.1 . The R12 EBS Techstack has been installed with 64bit staging and the O/S is also linux 5.6 x86_64 version. While upgrading the java by following the doc:455492.1, we stuck up with an error,