Received ORA-22818 subquery expressions not allowed here when creating mate

Hello,
I was trying to create a materialized view to describe the referential integrity between the tables in my schema:
create materialized view user_references
tablespace tbspc
build immediate
using index
refresh complete on demand next sysdate + 1
as
select uic.table_name to_table, uic.column_name to_column,
ucc.table_name from_table, ucc.column_name from_column
from user_ind_columns uic, user_constraints uc, user_cons_columns ucc
where uic.index_name = uc.r_constraint_name
and uc.constraint_name = ucc.constraint_name
and uc.owner=upper('my_schema');
I was able to create this MV in Oracle 9.2. It failed with the following error when I ran it against Oracle 10.1:
from user_ind_columns uic, user_constraints uc, user_cons_columns ucc
ERROR at line 9:
ORA-22818: subquery expressions not allowed here
Is not allowing subqueries in MV a new restriction in Oracle 10? Is there a workaround?
Thanks

Hello
This may be a bug in your version as I can do it successfully on 10.2
tylerd@DEV2> create materialized view user_references
  2  build immediate
  3  using index
  4  refresh complete on demand next sysdate + 1
  5  as
  6  select uic.table_name to_table, uic.column_name to_column,
  7  ucc.table_name from_table, ucc.column_name from_column
  8  from user_ind_columns uic, user_constraints uc, user_cons_columns ucc
  9  where uic.index_name = uc.r_constraint_name
10  and uc.constraint_name = ucc.constraint_name
11  and uc.owner=upper('my_schema');
Materialized view created.
tylerd@DEV2> select * from v$version
  2  /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
PL/SQL Release 10.2.0.2.0 - Production
CORE    10.2.0.2.0      Production
TNS for 32-bit Windows: Version 10.2.0.2.0 - Production
NLSRTL Version 10.2.0.2.0 - Production
5 rows selected.HTH
David

Similar Messages

  • ORA-22818: subquery expressions not allowed here

    I am currently optimizing my report. Before, this report has only a single query for all. But when I have revised it having subquery it is performing much more faster. The problem is, I cannot perform a calculation on my query since subquery expressions are not allowed in 'group by'. Heres my sample report:
    SELECT     ab.batch_name,
    ai.invoice_amount,
    ai.invoice_date,
    ai.invoice_num,
    ai.invoice_id,
         (SELECT     pv.vendor_name
         FROM     apps.po_vendors pv
         WHERE     pv.vendor_id = ai.vendor_id)vendor_name,
         aid.distribution_line_number,
         SUM(aid.amount * (atc.tax_rate/100))amount,
         (SELECT     gcc.segment2
         FROM     apps.gl_code_combinations gcc
         WHERE     gcc.code_combination_id = aid.dist_code_combination_id)segment2,
         (SELECT     gcc.segment5
         FROM     apps.gl_code_combinations gcc
         WHERE     gcc.code_combination_id = aid.dist_code_combination_id)segment5      
    FROM     apps.ap_batches_all ab,
              apps.ap_invoices_all ai,
              apps.ap_invoice_distributions_all aid,
              apps.ap_awt_groups aag,
              apps.ap_tax_codes_all atc
    WHERE     ab.batch_id = ai.batch_id
              AND ai.invoice_id = aid.invoice_id
              AND aag.group_id = aid.awt_group_id
    GROUP BY ab.batch_name,
    ai.invoice_amount,
    ai.invoice_date,
    ai.invoice_num,
    ai.invoice_id,
         (SELECT     pv.vendor_name
         FROM     apps.po_vendors pv
         WHERE     pv.vendor_id = ai.vendor_id),
         aid.distribution_line_number,
         (SELECT     gcc.segment2
         FROM     apps.gl_code_combinations gcc
         WHERE     gcc.code_combination_id = aid.dist_code_combination_id),
         (SELECT     gcc.segment5
         FROM     apps.gl_code_combinations gcc
         WHERE     gcc.code_combination_id = aid.dist_code_combination_id)
    Can anyone advise on what to do? I really need the computation part but at the same time I would like to optimize my report using subqueries.

    You dont need to group by the actual inline SQL/sub-query but only the columns you used from the main query ( ie, aid.dist_code_combination_id, ai.vendor_id )
    You also have to make sure that the in-line SQL you are using will return not more than 1 row.
    Also, why not just use a normal join (or outer join if necessary)?

  • Help regarding Materialized view ( subquery expression not allowed here )

    Hi all,
    while creating materialized view i got following error
    ORA- 22818
    subquery expression not allowed here
    following is my query
    CREATE  MATERIALIZED VIEW MV_NAV_REC
    BUILD IMMEDIATE
    REFRESH COMPLETE ON DEMAND
    as
    select folio_no FOLIONO,CHKDIGIT as Check_Digit,sch_code SCHEMECODE, sysdate as FOLIODATE ,
         (select case when count(distinct SUBBROKERCODE) =1 then to_char(max(SUBBROKERCODE)) else 'Multiple Broker' end   from transaction_st
         where folio_no = tst.folio_no
         group by  folio_no)  ARN_Number ,
         (select sum(case when tran_type in ('PURCHASE','SWITCH IN') then UNITS else 0 - UNITS end ) from transaction_st
         where folio_no = tst.folio_no AND SCH_CODE = tst.sch_code
         group by  folio_no,sch_code)  NUM_UNITS_NEW ,
    --SUM (case when tran_type NOT in ('REDEMPTION','SWITCH OUT') THEN UNITS ELSE 0 - UNITS END )  AS  Num_Units,
         (select sum(case when tran_type in ('PURCHASE','SWITCH IN') then AMOUNT else 0 - AMOUNT end ) from transaction_st
         where folio_no = tst.folio_no AND SCH_CODE = tst.sch_code
         group by  folio_no,SCH_CODE) as NUM_AMOUNT_NEW ,
    --SUM (case when tran_type NOT in ('REDEMPTION','SWITCH OUT') THEN AMOUNT ELSE 0 -AMOUNT  END )  AS  Scheme_Amount,
    sum(  CASE WHEN upper(tran_type) NOT in ('REDEMPTION','SWITCH OUT') THEN
                 units * (select nav_rs from nav_rec where nav_rec.sch_code = tst.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy'))
               ELSE  (0 - units) * (select nav_rs from nav_rec where nav_rec.sch_code = tst.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy')) END  ) Scheme_Valuation ,
    null as SCHEMEPHRASEID ,
    null as "Prefered Mode of SOA",
    (  select sum(      case when upper(tran_type) NOT in ('REDEMPTION','SWITCH OUT') THEN AMOUNT ELSE 0 - AMOUNT END  ) from transaction_st t where t.folio_no = tst.folio_no group by folio_no )  as Folio_Amount,
                   select sum(CASE when upper(tran_type) NOT in ('REDEMPTION','SWITCH OUT') THEN
                                              units * ( select nav_rs from nav_rec where nav_rec.sch_code = ts.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy'))
                                  ELSE
                                      (0 - units) * ( select nav_rs from nav_rec where nav_rec.sch_code = ts.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy')) END     
                                  )  from transaction_st ts where ts.folio_no =tst.folio_no  group by ts.folio_no
    ) as Folio_Valuation
    from transaction_st   tst 
    group by folio_no ,sch_code,CHKDIGIT
    order by folio_no , SCH_CODE
    please help me

    Hi,
    You cannot use scalar subqueries in a materialized view.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4110947624538#22981269011674
    edit
    From 10g doc:
    ORA-22818: subquery expressions not allowed here
    Cause: An attempt was made to use a subquery expression where these are not supported.
    Action: Rewrite the statement without the subquery expression.
    (http://download.oracle.com/docs/cd/B19306_01/server.102/b14219/e19400.htm#sthref6020)
    Edited by: hoek on Jun 10, 2009 7:56 AM

  • Materialized view is giving error ORA-22818 subquery expressions

    Hi all,
    i want to create one materilized view which will be combination of two tables and also having column sdatetime that is select from dual .
    CREATE MATERIALIZED VIEW E_VPN_MEMHISTORY
    PCTFREE 5 PCTUSED 60
    STORAGE (INITIAL 512K NEXT 1024K)
    REFRESH Fast
    AS SELECT (SELECT TO_CHAR(SYSDATE-1,'YYYYMMDDHH24MISS') FROM DUAL)sDateTime,m.sid,m.number,m.nAccUsg1,t.NACC1 FROM teacher m,student t where m.npid=t.npid and m.name=t.name(+);
    ORA-22818: subquery expressions not allowed here
    Cause: An attempt was made to use a subquery expression where these are not supported.
    Action: Rewrite the statement without the subquery expression.
    so what is the solution so that sdatetime should be there in view and it should be fast refresh.
    please suggest its urgent
    Edited by: 996962 on 10 Apr, 2013 9:20 AM

    >
    please suggest its urgent?:|
    Well, if you put it that way:
    I hereby suggest it's urgent....
    HTH!
    Seriously now, please read:
    {message:id=9360002}
    And the message should be clear:
    ORA-22818: subquery expressions not allowed here
    Cause: An attempt was made to use a subquery expression where these are not supported.
    Action: Rewrite the statement without the subquery expression.

  • Materialized view ....subquery expression not allowed

    Hi,
    I have been assigned to create a materialized view using the following subquery.
    When I executed it is giving error ora-22818:subquery expressions not allowed here. The same query is good for view but not MV.
    Can anybody help me in writing MV for my query.
    select rownum as ROWNUMBER,f.id Folder_ID, concatyear(f.id) year_name,
    (select nvl(fr.requestor,fr.requested_by) from fts_folder_request fr where
    fr.folder_id=f.id and fr.status=0 ) Pending_Requestor,
    (select nvl(fr.requestor,fr.requested_by)
    from fts_folder_request fr,fts_folder_checkout_history fch where
    fr.folder_id=f.id and fch.folder_requested=fr.id and fch.return_date is null) CheckOut_To from fts_folder f;
    Thanks in advance.

    Any help in creating MV for my query.It contains subquery expressions that have to be avoided in MV.
    select rownum as ROWNUMBER,f.id Folder_ID, concatyear(f.id) year_name,
    (select nvl(fr.requestor,fr.requested_by) from fts_folder_request fr where
    fr.folder_id=f.id and fr.status=0 ) Pending_Requestor,
    (select nvl(fr.requestor,fr.requested_by)
    from fts_folder_request fr,fts_folder_checkout_history fch where
    fr.folder_id=f.id and fch.folder_requested=fr.id and fch.return_date is null) CheckOut_To from fts_folder f;
    Thanks.
    Message was edited by:
    user617694

  • ORA-01733- virtual column not allowed here  - Insert using inline view

    Does anyone know why I am getting ORA-01733- virtual column not allowed here
    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
    ---no error without WITH CHECK option
    SQL> INSERT INTO
    2 (SELECT
    3 location_id,
    4 city,
    5 l.country_id
    6 FROM countries c, locations l,regions r
    7 where l.country_id = c.country_id
    8 and r.region_id=c.region_id
    9 and r.region_name = 'Asia')
    10 VALUES (5500, 'Wansdworth Common', 'UK');
    1 row created.
    SQL> rollback;
    Rollback complete.
    -----error with WITH CHECK OPTION
    SQL> INSERT INTO
    2 (SELECT
    3 location_id,
    4 city,
    5 l.country_id
    6 FROM countries c, locations l,regions r
    7 where l.country_id = c.country_id
    8 and r.region_id=c.region_id
    9 and r.region_name = 'Asia' WITH CHECK OPTION)
    10 VALUES (5500, 'Wansdworth Common', 'UK');
    INSERT INTO
    ERROR at line 1:
    ORA-01733: virtual column not allowed here
    I was expecting
    ORA-01402: view WITH CHECK OPTION where-clause violation
    for the second one. Is there anything I am missing here ?

    Randolf
    Thank you very much for the update to this old question
    After reading the link I think I should ignore this error and accept it as ORA-01402
    The information you asked me to check did not lead me an understanding of different error types.
    SQL> ----view for ORA-01733
    SQL> create view test_v_1
      2  as
      3  SELECT
      4  location_id,
      5  city,
      6  l.country_id
      7  FROM countries c, locations l,regions r
      8  where l.country_id = c.country_id
      9  and r.region_id=c.region_id
    10  and r.region_name = 'Asia' WITH CHECK OPTION;
    View created.
    SQL>
    SQL>
    SQL>
    SQL> select * from user_updatable_columns where table_name='TEST_V_1';
    OWNER                          TABLE_NAME                     COLUMN_NAME                    UPD INS DEL
    HR                             TEST_V_1                       CITY                           YES YES YES
    HR                             TEST_V_1                       COUNTRY_ID                     NO  NO  NO
    HR                             TEST_V_1                       LOCATION_ID                    YES YES YES
    SQL>
    SQL> ----view for ORA-01402
    SQL>
    SQL> create view test_v_2
      2  as
      3  SELECT
      4  d.department_id,
      5  d.department_name,
      6  d.location_id
      7  FROM hr.departments d,hr.locations l
      8  WHERE l.location_id=d.location_id
      9  and d.location_id < 2000
    10  WITH CHECK OPTION;
    View created.
    SQL>
    SQL> select * from user_updatable_columns where table_name='TEST_V_2';
    OWNER                          TABLE_NAME                     COLUMN_NAME                    UPD INS DEL
    HR                             TEST_V_2                       DEPARTMENT_ID                  YES YES YES
    HR                             TEST_V_2                       DEPARTMENT_NAME                YES YES YES
    HR                             TEST_V_2                       LOCATION_ID                    NO  NO  NO
    SQL>
    SQL>
    SQL> ----INSERT STILL FAILING WITH DIFFERENT ERROR DESPITE THE SAME UPDATABLE COLUMN STRUCTURE
    SQL> insert into test_v_1 values  (5500, 'Wansdworth Common', 'UK');
    insert into test_v_1 values  (5500, 'Wansdworth Common', 'UK')
    ERROR at line 1:
    ORA-01733: virtual column not allowed here
    SQL> insert into test_v_2 values  (9999, 'Entertainment', 2500);
    insert into test_v_2 values  (9999, 'Entertainment', 2500)
    ERROR at line 1:
    ORA-01402: view WITH CHECK OPTION where-clause violation
    SQL>A. Coskan GUNDOGAR
    Oracle DBA
    http://coskan.wordpress.com
    “A man's errors are his portals of discovery.”
    James Joyce

  • ORA-02253: constraint specification not allowed here

    I'm trying to create a table clients with primairy key, but I'm getting the error "ORA-02253: constraint specification not allowed here"
    if anyone call what to do
    CREATE TABLE CLIENTS
    NUMERO NUMBER(6) CONSTRAINT PK_CLIENTS PRIMAIRY KEY,
    NOM VARCHAR(63), NOT NULL,
    PRENOM VARCHAR(63),
    NAISSANCE DATE
    Edited by: user10397656 on Oct 13, 2008 1:40 AM

    There are some errors in your script :
    PK_CLIENTS PRIMAIRY KEY
    and
    NOM VARCHAR(63)*,* NOT NULL,
    Try this way
    CREATE TABLE CLIENTS
    NUMERO NUMBER(6) CONSTRAINT PK_CLIENTS PRIMARY KEY,
    NOM VARCHAR(63) NOT NULL,
    PRENOM VARCHAR(63),
    NAISSANCE DATE
    );

  • ORA-22902 CURSOR expression not allowed Error Cause: CURSOR on a subquery..

    Hi,
    I found same issue in a metalink thread which is addressed in Oracle 12.1 which doesn't help me now. I need to rewrite the below query. Does anyone have any suggestions how to go about it?
    thanks,
    April
    working in Oracle 11.2.0.3.1, windows server, doing an upgrade from 10g to 11g. Piece of code is failing with following error via TOAD
    Oracle Database Error Code ORA-22902 Description :
    CURSOR expression not allowed
    Error Cause:
    CURSOR on a subquery is allowed only in the top-level SELECT list of a query.
    The below code is returning a tree of data for projects, units within the buildings.
    Code as follows:
    SELECT LEVEL
    , p.project_id
    || NVL (p.file_ref, ' ')
    || '] ['
    || NVL (p.project_ref, ' ')
    || '] '
    || p.project_name
    || ' ( '
    || (SELECT COUNT (*)
    FROM PROJECT p1
    WHERE p1.parent_project_id = p.project_id)
    || ' sub-projects, '
    || (SELECT COUNT (*)
    FROM PROJECT_ELEMENT pe2
    WHERE pe2.project_id = p.project_id)
    || ' elements)' AS project_description
    CURSOR
    (SELECT pe.element_id
    || pe.element_ref
    || '] '
    || pe.element_name
    || ' ('
    || pe.unit_count
    || ')' AS element_description
    CURSOR
    (SELECT hu.hu_id
    || hu.hu_ref
    || '] '
    || CASE
    WHEN hu.bedroom_count IS NOT NULL
    THEN ', Bedrooms: ' || hu.bedroom_count
    ELSE NULL
    END
    || CASE
    WHEN hu.bedspace_count IS NOT NULL
    THEN ', Bedspaces: ' || hu.bedspace_count
    ELSE NULL
    END AS hu_descripton
    FROM HOUSING_UNIT hu
    WHERE hu.element_id = pe.element_id
    ORDER BY hu.hu_ref
    ) AS housing_units
    FROM PROJECT_ELEMENT pe
    WHERE pe.project_id = p.project_id
    ORDER BY pe.element_ref, pe.element_name
    ) elements
    FROM PROJECT p
    START WITH p.project_id = l_root_project_id
    CONNECT BY PRIOR p.project_id = p.parent_project_id -- connect by used with LEVEL keyword
    ORDER SIBLINGS BY p.file_ref DESC
    , p.project_ref DESC
    , p.project_name DESC;
    Edited by: AprilM on Jul 17, 2012 10:28 AM

    Interesting. I am getting even worse results on 11.2.0.1.0:
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL> select dname,cursor(select ename from emp e where e.deptno = d.deptno) from dept d
      2  /
    select dname,cursor(select ename from emp e where e.deptno = d.deptno) from dept d
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-00905: missing keyword
    SQL> connect scott
    Enter password: *****
    Connected.
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> select dname,cursor(select ename from emp e where e.deptno = d.deptno) from dept d
      2  /
    DNAME          CURSOR(SELECTENAMEFR
    ACCOUNTING     CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    ENAME
    CLARK
    KING
    MILLER
    RESEARCH       CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    ENAME
    SMITH
    JONES
    SCOTT
    ADAMS
    FORD
    SALES          CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    ENAME
    ALLEN
    WARD
    MARTIN
    BLAKE
    TURNER
    JAMES
    6 rows selected.
    OPERATIONS     CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    no rows selected
    SQL> And double CURSOR also works fine in 10g:
    SQL> select cursor(select dname,cursor(select ename from emp e where e.deptno = d.deptno) from dept d) from dual
      2  /
    CURSOR(SELECTDNAME,C
    CURSOR STATEMENT : 1
    CURSOR STATEMENT : 1
    DNAME          CURSOR(SELECTENAMEFR
    ACCOUNTING     CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    ENAME
    CLARK
    KING
    MILLER
    RESEARCH       CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    ENAME
    SMITH
    JONES
    SCOTT
    ADAMS
    FORD
    SALES          CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    ENAME
    ALLEN
    WARD
    MARTIN
    BLAKE
    TURNER
    JAMES
    6 rows selected.
    OPERATIONS     CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    no rows selectedSY.
    Edited by: Solomon Yakobson on Jul 17, 2012 1:27 PM

  • ORA-02287 sequence number not allowed here

    Hello
    Could someone tell my why I get this error with the following select?
    create sequence dt_test_seq start with 1 increment by 1;
    create table dt_test_tab (col1 number,col2 number, col3 number);
    insert into dt_test_tab values(1,1,1);
    insert into dt_test_tab values(1,1,1);
    insert into dt_test_tab values(1,2,2);
    insert into dt_test_tab values(2,2,3);
    insert into dt_test_tab values(2,2,3);
    select
         col1,
         col2,
         col3,
         NVL(next_val,LAG(next_val) over(partition by col1,col2 order by col1,col2))
    from
         select
              col1,
              col2,
              col3,
              CASE
                   WHEN  row_number() over (partition by col1,col2 order by col1,col2) = 1 THEN
                        dt_test_seq.nextval
              END next_val
         FROM
              dt_test_tab
         );I came across the problem while trying to come up with a single query answer to the post:Re: Call a function only on change of group of columns
    The inner query works fine but the error comes when it is turned into an inline view and apply a function to the next_val column.
    It's more out of curiosity than anything else as the answer that dmitry posted is obviously the right way to do it?
    And yes, I am very bored ;-)
    David

    SQL> create function getnextval return number
    2 is
    3 id number;
    4 begin
    5 select dt_test_seq.nextval into id from dual;
    6 return id;
    7 end;
    8 /
    Function created.
    SQL> edit
    Wrote file afiedt.buf
    1 select
    2 col1,
    3 col2,
    4 col3,
    5 CASE
    6 WHEN row_number() over (partition by col1,col2 order by col1,col2) = 1 THEN
    7 getnextval
    8 END next_val
    9 FROM
    10* dt_test_tab
    SQL> /
    COL1 COL2 COL3 NEXT_VAL
    1 1 1 99
    1 1 1
    1 2 2 100
    2 2 3 101
    2 2 3
    SQL> edit
    Wrote file afiedt.buf
    1 select
    2 col1,
    3 col2,
    4 col3,
    5 NVL(next_val,LAG(next_val) over(partition by col1,col2 order by col1,col2)) next_v
    6 from
    7 (
    8 select
    9 col1,
    10 col2,
    11 col3,
    12 CASE
    13 WHEN row_number() over (partition by col1,col2 order by col1,col2) = 1 THEN
    14 getnextval
    15 END next_val
    16 FROM
    17 dt_test_tab
    18* )
    SQL> /
    COL1 COL2 COL3 NEXT_V
    1 1 1 105
    1 1 1 105
    1 2 2 106
    2 2 3 107
    2 2 3 107
    Is it what you need ?
    Rgds.
    But I am afraid it's not what you need, am I not ?

  • PL/SQL: ORA-00984: column not allowed here

    I am Trying to compile this procedure, but i get error, could please anybody help me out.
    Thanks.
    SQL> create or replace procedure FOF_sport_setup(
    2 v_model_cd in varchar2, -- model_cd used in many place
    3 v_portfolio_name in varchar2, -- portfolio name
    4 v_src_acct_nbr in varchar2, -- source account number for port
    5 v_src_fund_nbr in varchar2, -- source fund number
    6 v_fmr_fund_nbr in varchar2, -- fidelity fund number
    7 v_src_cd in varchar2, -- source code
    8 v_last_mod_id in varchar2 -- your corp id
    9 )
    10 as
    11 v_new_portf_id number(12);
    12
    13 begin
    14
    15 select max(portf_id) into v_new_portf_id from portfolios;
    16
    17 insert into portfolios
    18 (portf_id,
    19 portf_cd,
    20 portf_name,
    21 portf_typ_cd,
    22 inception_date,
    23 sub_product_cd,
    24 product_cd,
    25 product_line_cd,
    26 bus_line_cd,
    27 dly_perf_restr_ind,
    28 portf_mgr_id,
    29 seed_acct_nbr,
    30 use_epas_ind,
    31 epas_drop_perf_ind,
    32 src_acct_nbr,
    33 src_fund_nbr,
    34 fmr_fund_nbr,
    35 src_cd,
    36 last_mod_id,
    37 last_mod_dt)
    38 values
    39 (new_portf_id,
    40 v_model_cd,
    41 v_portfolio_name,
    42 "RETAIL",
    43 v_inception_date,
    44 "FREE",
    45 "FREE",
    46 "FREE",
    47 "PAS",
    48 "Yes",
    49 3,
    50 "31635C101",
    51 "N",
    52 "Y",
    53 v_src_acct_nbr,
    54 v_src_fund_nbr,
    55 v_fmr_fund_nbr,
    56 v_src_cd,
    57 v_last_mod_id,
    58 sysdate);
    59
    60 end;
    61 /
    Warning: Procedure created with compilation errors.
    SQL> show errors procedure FOF_sport_setup
    Errors for PROCEDURE FOF_SPORT_SETUP:
    LINE/COL ERROR
    17/2 PL/SQL: SQL Statement ignored
    51/3 PL/SQL: ORA-00984: column not allowed here
    SQL>

    create or replace procedure FOF_sport_setup(
    v_model_cd in varchar2, -- model_cd used in many places for portf_id,
    v_portfolio_name in varchar2, -- portfolio name
    v_inception_date in varchar2,
    v_src_acct_nbr in varchar2, -- source account number for portfolio table in sport db
    v_src_fund_nbr in varchar2, -- source fund number
    v_fmr_fund_nbr in varchar2, -- fidelity fund number
    v_src_cd in varchar2, -- source code
    v_last_mod_id in varchar2 -- your corp id
    as
    v_new_portf_id number(12);
    begin
    select max(portf_id) into v_new_portf_id from portfolios;
    insert into portfolios
    (portf_id,
    portf_cd,
    portf_name,
    portf_typ_cd,
    inception_date,
    sub_product_cd,
    product_cd,
    product_line_cd,
    bus_line_cd,
    dly_perf_restr_ind,
    portf_mgr_id,
    seed_acct_nbr,
    use_epas_ind,
    epas_drop_perf_ind,
    src_acct_nbr,
    src_fund_nbr,
    fmr_fund_nbr,
    src_cd,
    last_mod_id,
    last_mod_dt)
    values
    (v_new_portf_id,
    v_model_cd,
    v_portfolio_name,
    'RETAIL',
    to_date('v_inception_date'),
    'FREE',
    'FREE',
    'FREE',
    'PAS',
    'Yes',
    3,
    '31635C101',
    'N',
    'Y',
    v_src_acct_nbr,
    v_src_fund_nbr,
    v_fmr_fund_nbr,
    v_src_cd,
    v_last_mod_id,
    sysdate);
    end;
    =====================
    The procedure got created without any errors, when i am trying to execute the procedure i am getting errors.
    this is the parameters which i am passing:
    exec FOF_sport_setup('01213', 'PAS International Fund of Funds', '2/15/2006', '01213', 'IFOFB', 'IFOFB', 'FPCMS', 'a382077')
    SQL> exec FOF_sport_setup('01213', 'PAS International Fund of Funds', '2/15/2006', '01213', 'IFOFB',
    'IFOFB', 'FPCMS', 'a382077')
    BEGIN FOF_sport_setup('01213', 'PAS International Fund of Funds', '2/15/2006', '01213', 'IFOFB', 'IF
    ERROR at line 1:
    ORA-01858: a non-numeric character was found where a numeric was expected
    ORA-06512: at "SPORT.FOF_SPORT_SETUP", line 15
    ORA-06512: at line 1
    ===============
    the description for the table is below
    ===========
    SQL> desc portfolios
    Name Null? Type
    PORTF_ID NOT NULL NUMBER(25)
    PORTF_CD VARCHAR2(10)
    PORTF_NAME VARCHAR2(60)
    STRATEGY_CD VARCHAR2(10)
    CO_STOCK_LEV_CD VARCHAR2(10)
    EFF_DATE DATE
    PORTF_WEB_NAME VARCHAR2(60)
    PORTF_TYP_CD VARCHAR2(10)
    INCEPTION_DATE DATE
    CLOSE_DATE DATE
    SUB_PRODUCT_CD VARCHAR2(10)
    PRODUCT_CD VARCHAR2(10)
    PRODUCT_LINE_CD VARCHAR2(10)
    BUS_LINE_CD VARCHAR2(10)
    BUS_GRP_CD VARCHAR2(10)
    PLAN_CD VARCHAR2(10)
    ADVISOR_CD VARCHAR2(10)
    RISK_LEVEL_CD VARCHAR2(10)
    DLY_PERF_RESTR_IND VARCHAR2(3)
    SUB_PORTF_IND CHAR(1)
    PORTF_MGR_ID NUMBER(25)
    SEED_ACCT_NBR VARCHAR2(9)
    OBJECTIVE VARCHAR2(255)
    PORTF_COMPOSITION_DESC VARCHAR2(50)
    LGL_GRP VARCHAR2(30)
    USE_EPAS_IND VARCHAR2(3)
    EPAS_MODEL_NAME VARCHAR2(50)
    EPAS_DROP_PERF_IND VARCHAR2(3)
    SRC_ACCT_NBR VARCHAR2(15)
    SRC_FUND_NBR VARCHAR2(6)
    FMR_FUND_NBR VARCHAR2(6)
    NET_ASSETS NUMBER(25,8)
    SEED_MKT_VAL NUMBER(25,10)
    ACCT_MKT_VAL NUMBER(25,10)
    TOTAL_ASSETS NUMBER(25,10)
    NET_OTHER_ASSETS NUMBER(25,8)
    ACCRUED_INCOME NUMBER(25,10)
    ACCRUED_INTEREST NUMBER
    LIABILITIES NUMBER(25,10)
    SHARES_OUTSTANDING NUMBER(25,10)
    PRINCIPAL_CASH NUMBER(25,10)
    INCOME_CASH NUMBER(25,10)
    INVESTIBLE_CASH NUMBER(25,10)
    SHIP_DATE DATE
    REBALANCE_IND CHAR(1)
    OUTBOUND_IND VARCHAR2(5)
    LGL_MSG_CD CHAR(1)
    LAST_SETTLE_DATE DATE
    LAST_TRD_DATE DATE
    LAST_ALLOC_DATE DATE
    STATUS_CD CHAR(1)
    SRC_CD NOT NULL VARCHAR2(5)
    LAST_MOD_ID NOT NULL VARCHAR2(10)
    LAST_MOD_DT NOT NULL DATE
    PORTF_MGD_CD VARCHAR2(10)
    ==========

  • Seq # not allowed here

    while executing the below query. I m getting this error ora error 02287 " sequence # not allowed here"
            SELECT SVC_ORD_DETAIL_ID.NEXTVAL,
                   K.SVC_ORDER_ID,
                   'RELEASED_DATE',
                   K.RELEASEDT
            FROM (SELECT S.SVC_ORDER_ID,
                         TO_DATE(T.RELSD_DT||T.RELSD_TM,'yyyymmddhh24miss') AS RELEASEDT
                         FROM IONS09MAR12.SVC_ORDER S,
                         M09_NT_UV_IMPLEMENT_PLAN T
                   WHERE S.ORDER_NUMBER(+) = T.PLAN_ID) K;

    As I predicted then.
    Below is extract from Oracle Documentation:-
    Restrictions on Sequence Values You cannot use CURRVAL and NEXTVAL in the
    following constructs:
    A subquery in a DELETE, SELECT, or UPDATE statement
    A query of a view or of a materialized view
    A SELECT statement with the DISTINCT operator
    A SELECT statement with a GROUP BY clause or ORDER BY clause
    A SELECT statement that is combined with another SELECT statement with the
    UNION, INTERSECT, or MINUS set operator
    The WHERE clause of a SELECT statement
    The DEFAULT value of a column in a CREATE TABLE or ALTER TABLE statement
    The condition of a CHECK constraint
    _Within a single SQL statement that uses CURRVAL or NEXTVAL, all referenced LONG_
    _columns, updated tables, and locked tables must be located on the same database._

  • ORA-00934: group function is not allowed here

    Hi,
    My requirement is to check oi.quantity is equal to sum of packing_detail. quantity
    by order_number
    select oi.quantity_ordered oi_qu, pd.quantity pq
    from ordered_items oi, packing_details pd
    where oi.ordered_item_id = pd.ordered_item_id
    and oi.quantity_ordered = sum(pd.quantity)
    and oi.order_number = '29';
    after executing above query I get error
    SQL Error: ORA-00934: group function is not allowed here
    00934. 00000 - "group function is not allowed here"
    Please tell me how to resolve it.
    Thanks in advance
    Sandy

    You have to make use of a subquery;
    select oi.quantity_ordered oi_qu, pd.quantity pq
    from ordered_items oi, packing_details pd 
    where oi.ordered_item_id = pd.ordered_item_id 
    and oi.quantity_ordered = *(select sum(pd.quantity) from packing_details pd1 group by pd1.ordered_item_id)* 
    and oi.order_number = '29';  This is based on the assumption that ordered_items is the summarize data and packing_details are the line item level data.
    regards,
    Dipankar.

  • PL/SQL: ORA-00934: group function is not allowed here

    Hi,
    I am writing a PL/SQL procedure. The structure is like :
    SET SERVEROUTPUT ON;
    CREATE OR REPLACE Procedure abc
    IS
    v_total_ip_rec number(14);
    v_total_op_rec number(14);
    v_total_rec number(14);
    BEGIN
    SELECT SUM (CASE
    WHEN <condition 1>
    THEN 1
    ELSE 0
    END
    ) into v_total_ip_rec,
    SUM (CASE
    WHEN <condition 2>
    THEN 1
    ELSE 0
    END
    ) into v_total_op_rec,
    SUM (1) into v_total_rec
    FROM A,B
    WHERE A.Col1=B.Col1;
    EXCEPTION
    WHEN OTHERS THEN
    raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    END;
    When I run this procedure it gives me following error:
    "PL/SQL: ORA-00934: group function is not allowed here"
    Anybody have any idea?
    Any help would be appreciated.
    Thanks.

    Hi Arunkumar ,
    I think you don't need subquery.
    Regards Salim.
    Or.
    SELECT COUNT (CASE
                     WHEN <condition 1>
                        THEN 1
                  END) v_total_ip_rec,
           COUNT (CASE
                     WHEN <condition 2>
                        THEN 1
                  END) v_total_op_rec,
           COUNT (1) v_total_rec
      FROM a, b
    WHERE a.col1 = b.col1

  • ORA-00976: Specified pseudocolumn or operator not allowed here

    Hi,
    After 11gR2 upgrade we got error in insert statement.
    INSERT INTO SDE_TBL_FLEXTRIMSITROUT
    (BRANCHCD,
    SOURCECD,
    CURRENTNO,
    BATCHNO,
    DEPTCD,
    CCY,
    INITIATIONDATE,
    AMOUNT,
    ACCOUNT,
    ACCOUNTBRANCH,
    TXNCD,
    DEBITCREDIT,
    LCYEQUIVALENT,
    EXCHRATE,
    VALUEDATE,
    INSTRUMENTNO,
    RELCUST,
    ADDLTEXT,
    TXNMIS1,
    TXNMIS2,
    TXNMIS3,
    TXNMIS4,
    TXNMIS5,
    TXNMIS6,
    TXNMIS7,
    TXNMIS8,
    TXNMIS9,
    TXNMIS10,
    COMPMIS1,
    COMPMIS2,
    COMPMIS3,
    COMPMIS4,
    COMPMIS5,
    COMPMIS6,
    COMPMIS7,
    COMPMIS8,
    COMPMIS9,
    COMPMIS10,
    COSTCODE1,
    COSTCODE2,
    COSTCODE3,
    COSTCODE4,
    COSTCODE5,
    RELATEDACCOUNT,
    RELATEDREF,
    USERREFERENCE,
    ACCTPOSTOVERWRITE,
    EXCHRATEOVERWRITE,
    VALUEDATEOVERWRITE,
    ACCTBALOVERWRITE,
    ITRREFER,
    RefinanceAmount,
    PROCESSID)
    VALUES
    (vBranchCode,
    cCreateNewTrimsITR_rec.APPLSYS,
    ROWNUM,
    nBatchNo,
    cCreateNewTrimsITR_rec.DEPT,
    vCcy,
    TO_DATE(cCreateNewTrimsITR_rec.TRANSDATE, 'YYYYMMDD'),
    nAmount,
    vAccount,
    vAccountBranch, --added by subhashish
    vTxnCd,
    cDebitCredit,
    nLcyEquivalent,
    nExchRate,
    TO_DATE(cCreateNewTrimsITR_rec.VALUEDATE, 'YYYYMMDD'),
    vInstrumentNo,
    --'      ' || SUBSTR(cCreateNewTrimsITR_rec.ITRREFER,2,11),
    vFlxCntry || cCreateNewTrimsITR_rec.APNO,
    vDesc,
    cCreateNewTrimsITR_rec.TRANSOUC,
    RPAD(' ', 9),
    vExpenseMIS,
    vProductMIS,
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 9),
    RPAD(' ', 20),
    cCreateNewTrimsITR_rec.THEIRREF,
    RPAD(' ', 16),
    cActPostOverwrite,
    cExchRateOverWrite,
    cValueDateOverWrite,
    cAcctBalOverWrite,
    cCreateNewTrimsITR_rec.ITRREFER,
    cCreateNewTrimsITR_rec.REFIAMOUNT,
    nFlexOutProcessId);
    Error : ORA-00976: Specified pseudocolumn or operator not allowed here
    As per checking, found there is an issue in 11gR2 with insert query using rownum in values.
    Do anyone know how to solve this issue ?

    If there is a bug here, then it is in 10g, not 11.  Although it does insert a row, I don't think it does anything useful.
    SQL> create table t (id number, descr varchar2(10));
    Table created.
    SQL> insert into t values (rownum, 'One');
    1 row created.
    SQL> select * from t;
              ID DESCR
               0 One
    SQL> insert into t values (rownum, 'Two');
    1 row created.
    SQL> select * from t;
              ID DESCR
               0 One
    SQL> commit;
    Commit complete.
    SQL> insert into t values (rownum, 'Three');
    1 row created.
    SQL> select * from t;
              ID DESCR
               0 One
               0 Two
               0 Three
    John

  • ORA-04044: procedure, function, package, or type is not allowed here

    Hi,
    I am trying to build an object hierarchy.The object hirarcy is for a multi division, multi department, multi cost center and multi operation Organisation.Multiple department can store into multiple divisions, multiple cost center can store into multiple departments, multiple operations can store into multiple cost centers.
    The structure I try to built like this:
    create type div_obj_new as object
    (id number,
    divdesc varchar2(100)
    create type div_obj_tab as
    table of div_obj_new
    create type dept_obj_new as object
    (id number,
    deptdesc varchar2(100),
    dept_div number
    create type dept_obj_tab as
    table of dept_obj_new
    create type cctr_obj_new as object
    (id number,
    cctrdesc varchar2(100),
    cctr_dept number
    create type cctr_obj_tab as
    table of cctr_obj_new
    create type oper_obj_new as object
    (id number,
    operdesc varchar2(100),
    oper_cctr number
    create type oper_obj_tab as
    table of oper_obj_new
    ==========================
    create type div_obj_type as object
    (divid div_obj_tab)
    NOT FINAL
    create type dept_obj_type under div_obj_type
    (deptid dept_obj_tab)
    NOT FINAL
    create type cctr_obj_type under dept_obj_type
    (cctrid cctr_obj_tab)
    NOT FINAL
    create type oper_obj_type under cctr_obj_type
    (operid oper_obj_tab)
    NOT FINAL
    =======This Table creation is not working=================
    create table organisation
    (div div_obj_type,
    dept dept_obj_type,
    cctr cctr_obj_type,
    oper oper_obj_type)
    nested table div store as division_table
    nested table dept store as department_table
    nested table cctr store as costcntr_table
    nested table oper store as operation_table
    nested table oper store as operation_table
    ERROR at line 9:
    ORA-22912: specified column or attribute is not a nested table type
    =========================================================
    Then I try to insert record into the div_obj_type instead of organisation table as it was not working.
    The insert script is as follows:
    ===================================
    insert into div_obj_type values
    div_obj_tab
    (div_obj_new(01,'Division 01'),
    div_obj_new(02,'Division 02'),
    div_obj_new(03,'Division 03'),
    div_obj_new(04,'Division 04')
    dept_obj_tab
    dept_obj_new(10,'Department 10',1),
    dept_obj_new(11,'Department 11',1),
    dept_obj_new(12,'Department 12',2),
    dept_obj_new(13,'Department 13',3),
    dept_obj_new(14,'Department 14',4),
    dept_obj_new(15,'Department 15',5),
    dept_obj_new(16,'Department 16',6),
    dept_obj_new(17,'Department 17',7)
    cctr_obj_tab
    cctr_obj_new(100,'Cost Center 100',10),
    cctr_obj_new(101,'Cost Center 101',11),
    cctr_obj_new(100,'Cost Center 102',12),
    cctr_obj_new(100,'Cost Center 103',13),
    cctr_obj_new(100,'Cost Center 104',14),
    cctr_obj_new(100,'Cost Center 105',15),
    cctr_obj_new(100,'Cost Center 106',16),
    cctr_obj_new(100,'Cost Center 107',17),
    cctr_obj_new(100,'Cost Center 108',10),
    cctr_obj_new(100,'Cost Center 109',11),
    cctr_obj_new(100,'Cost Center 110',12)
    oper_obj_tab
    oper_obj_new(1000,'Operation 1000',100),
    oper_obj_new(1000,'Operation 1001',101),
    oper_obj_new(1000,'Operation 1002',102),
    oper_obj_new(1000,'Operation 1003',103),
    oper_obj_new(1000,'Operation 1004',104),
    oper_obj_new(1000,'Operation 1005',105),
    oper_obj_new(1000,'Operation 1006',106),
    oper_obj_new(1000,'Operation 1007',107),
    oper_obj_new(1000,'Operation 1008',108),
    oper_obj_new(1000,'Operation 1009',109),
    oper_obj_new(1000,'Operation 1010',110),
    oper_obj_new(1000,'Operation 1011',101),
    oper_obj_new(1000,'Operation 1012',102),
    oper_obj_new(1000,'Operation 1013',103),
    oper_obj_new(1000,'Operation 1014',104),
    oper_obj_new(1000,'Operation 1015',105),
    oper_obj_new(1000,'Operation 1016',106),
    oper_obj_new(1000,'Operation 1017',107),
    oper_obj_new(1000,'Operation 1018',108)
    insert into div_obj_type values
    ERROR at line 1:
    ORA-04044: procedure, function, package, or type is not allowed here
    Actually I want to create an object view or object table with all the details of division, department , cost center and operation and it will store depending upon the respective upper level hirarcy 's id.For eg. department details can be fetched through division id etc..
    So I can't figure out what to do for this kind of structure and how to do that.
    I am running Oracle Release 2 (9.2.0.1.0) for Windows 2000.
    Any help , advice or suggestions will be appreciated.
    Thanks & Regards
    Nihar

    Hi Cameron,
    Thanks for your great suggestion.Actually what you have suggested is correct and it was tested by me correctly.But actually I want to store records in the multiple objects hirarcy depending upon the respective upper level hirarcy 's id.For say how can I retrive all records related to divisionID which is in the top level hirarchy? So by selecting divisionID=01, how can I easily select all depts,cost centers and Operation details?
    Again I have another problem , when try to retrive record using PL/SQL I got some problem.
    Structure as created above.Again I am giving here.
    create type div_obj_new as object
    (id number,
    divdesc varchar2(100)
    create type div_obj_tab as
    table of div_obj_new
    create type dept_obj_new as object
    (id number,
    deptdesc varchar2(100),
    dept_div number
    create type dept_obj_tab as
    table of dept_obj_new
    create type cctr_obj_new as object
    (id number,
    cctrdesc varchar2(100),
    cctr_dept number
    create type cctr_obj_tab as
    table of cctr_obj_new
    create type oper_obj_new as object
    (id number,
    operdesc varchar2(100),
    oper_cctr number
    create type oper_obj_tab as
    table of oper_obj_new
    create table organisation
    (div div_obj_tab,
    dept dept_obj_tab,
    cctr cctr_obj_tab,
    oper oper_obj_tab)
    nested table div store as division_table
    nested table dept store as department_table
    nested table cctr store as costcntr_table
    nested table oper store as operation_table
    insert into organisation values
    div_obj_tab
    (div_obj_new(01,'Division 01'),
    div_obj_new(02,'Division 02'),
    div_obj_new(03,'Division 03'),
    div_obj_new(04,'Division 04')
    dept_obj_tab
    dept_obj_new(10,'Department 10',1),
    dept_obj_new(11,'Department 11',1),
    dept_obj_new(12,'Department 12',2),
    dept_obj_new(13,'Department 13',3),
    dept_obj_new(14,'Department 14',4),
    dept_obj_new(15,'Department 15',5),
    dept_obj_new(16,'Department 16',6),
    dept_obj_new(17,'Department 17',7)
    cctr_obj_tab
    cctr_obj_new(100,'Cost Center 100',10),
    cctr_obj_new(101,'Cost Center 101',11),
    cctr_obj_new(100,'Cost Center 102',12),
    cctr_obj_new(100,'Cost Center 103',13),
    cctr_obj_new(100,'Cost Center 104',14),
    cctr_obj_new(100,'Cost Center 105',15),
    cctr_obj_new(100,'Cost Center 106',16),
    cctr_obj_new(100,'Cost Center 107',17),
    cctr_obj_new(100,'Cost Center 108',10),
    cctr_obj_new(100,'Cost Center 109',11),
    cctr_obj_new(100,'Cost Center 110',12)
    oper_obj_tab
    oper_obj_new(1000,'Operation 1000',100),
    oper_obj_new(1000,'Operation 1001',101),
    oper_obj_new(1000,'Operation 1002',102),
    oper_obj_new(1000,'Operation 1003',103),
    oper_obj_new(1000,'Operation 1004',104),
    oper_obj_new(1000,'Operation 1005',105),
    oper_obj_new(1000,'Operation 1006',106),
    oper_obj_new(1000,'Operation 1007',107),
    oper_obj_new(1000,'Operation 1008',108),
    oper_obj_new(1000,'Operation 1009',109),
    oper_obj_new(1000,'Operation 1010',110),
    oper_obj_new(1000,'Operation 1011',101),
    oper_obj_new(1000,'Operation 1012',102),
    oper_obj_new(1000,'Operation 1013',103),
    oper_obj_new(1000,'Operation 1014',104),
    oper_obj_new(1000,'Operation 1015',105),
    oper_obj_new(1000,'Operation 1016',106),
    oper_obj_new(1000,'Operation 1017',107),
    oper_obj_new(1000,'Operation 1018',108)
    ===============
    declare
    div number;
    divdesc varchar2(100);
    divdetails varchar2(100);
    dept number;
    deptdesc varchar2(100);
    deptdetails varchar2(100);
    cctr number;
    cctrdesc varchar2(100);
    cctrdetails varchar2(100);
    oper number;
    operdesc varchar2(100);
    operdetails varchar2(100);
    cursor c_div is
    select d.id , d.divdesc from table(select div from organisation) d
    where d.id=1;
    --union
    cursor c_dept is
    select dp.id , dp.deptdesc "Dept Details" from table(select dept from organisation) dp
    where dp.dept_div=1;
    --union
    cursor c_cctr is
    select cc.id , cc.cctrdesc "Cctr Details" from table(select cctr from organisation ) cc
    where cc.cctr_dept=10;
    --union
    cursor c_oper is
    select op.id , op.operdesc "Oper Details" from table(select oper from organisation) op
    where op.oper_cctr=100;
    TYPE oper_type IS RECORD
    (oper_no NUMBER,
    oper_desc VARCHAR(50));
    TYPE cctr_type IS RECORD
    (cctr_no NUMBER,
    cctr_desc VARCHAR(50),
         oper_detl oper_type);
    TYPE dept_type IS RECORD
    (dept_no NUMBER,
    dept_desc VARCHAR(50),
         cctr_detl cctr_type);
    TYPE div_type IS RECORD
    (div_no NUMBER,
    div_desc VARCHAR2(50),
    dept_detl dept_type);
         division_rec div_type;
    begin
    for i_div in c_div%rowcount
         loop
         exit when c_div%notfound;
         division_rec.div_no:=i_div.id;
         division_rec.div_desc:=i_div.divdesc;
         dbms_output.put_line('Division details = ' || division_rec.div_no || division_rec.div_desc);
    --end loop;
    for i_dept in c_dept%rowcount
         loop
         exit when c_dept%notfound;
         select dp.id , dp.deptdesc ,
         into
         division_rec.dept_detl.dept_no, division_rec.dept_detl.dept_desc
         from
         table(select dept from organisation) dp
         where dp.dept_div=division_rec.div_no;
    -- division_rec.dept_detl.dept_no:=c_dept.id;
    -- division_rec.dept_detl.dept_desc:=c_dept.deptdesc;
         dbms_output.put_line('Department details = ' || division_rec.dept_detl.dept_no ||      
    division_rec.dept_detl.dept_desc);
    --end loop;
         for i_cctr in c_cctr
              loop
              exit when c_cctr%notfound;
              select cc.id , cc.cctrdesc
              into
              division_rec.dept_detl.cctr_detl.cctr_no ,           
    division_rec.dept==_detl.cctr_detl.cctr_desc
              from
              table(select cctr from organisation ) cc
              where cc.cctr_dept=division_rec.dept_detl.dept_no;
    -- division_rec.dept_detl.cctr_detl.cctr_no:=c_cctr.id;
    -- division_rec.dept_detl.cctr_detl.cctr_desc:=c_cctr.cctrdesc;
         dbms_output.put_line('Cost Center details = ' || division_rec.dept_detl.cctr_detl.cctr_no ||
         division_rec.dept_detl.cctr_detl.cctr_desc);
    --end loop;
              for i_oper in c_oper%rowcount
                   loop
                   exit when c_oper%notfound;
              select op.id , op.operdesc
              into
              division_rec.dept_detl.cctr_detl.oper_detl.oper_no,           
    division_rec.dept_detl.cctr_detl.oper_detal.oper_desc
              from
              table(select oper from organisation) op
              where op.oper_cctr=division_rec.dept_detl.cctr_detl.cctr_no;
    -- division_rec.dept_detl.cctr_detl.oper_detl.oper_no:=c_oper.id;
    -- division_rec.dept_detl.cctr_detl.oper_detal.oper_desc:=c_oper.operdesc;
         dbms_output.put_line('Operation details = ' ||
    division_rec.dept_detl.cctr_detl.oper_detl.oper_no ||
    division_rec.dept_detl.cctr_detl.oper_detal.oper_desc);
    end loop;
    end loop;
    end loop;
    end loop;
    end;
    for i_div in c_div%rowcount
    ERROR at line 46:
    ORA-06550: line 46, column 14:
    PLS-00999: implementation restriction (may be temporary)
    ORA-06550: line 46, column 1:
    PL/SQL: Statement ignored
    New version of PL/SQL bloc
    ==============================
    declare
    div number;
    divdesc varchar2(100);
    divdetails varchar2(100);
    dept number;
    deptdesc varchar2(100);
    deptdetails varchar2(100);
    cctr number;
    cctrdesc varchar2(100);
    cctrdetails varchar2(100);
    oper number;
    operdesc varchar2(100);
    operdetails varchar2(100);
    cnt_div number;
    cnt_dept number;
    cnt_cctr number;
    cnt_oper number;
    cursor c_div is
    select d.id , d.divdesc from table(select div from organisation) d
    where d.id=1;
    --union
    cursor c_dept is
    select dp.id , dp.deptdesc from table(select dept from organisation) dp
    where dp.dept_div=1;
    --union
    cursor c_cctr is
    select cc.id , cc.cctrdesc from table(select cctr from organisation ) cc
    where cc.cctr_dept=10;
    --union
    cursor c_oper is
    select op.id , op.operdesc from table(select oper from organisation) op
    where op.oper_cctr=100;
    TYPE oper_type IS RECORD
    (oper_no NUMBER,
    oper_desc VARCHAR(50));
    TYPE cctr_type IS RECORD
    (cctr_no NUMBER,
    cctr_desc VARCHAR(50),
         oper_detl oper_type);
    TYPE dept_type IS RECORD
    (dept_no NUMBER,
    dept_desc VARCHAR(50),
         cctr_detl cctr_type);
    TYPE div_type IS RECORD
    (div_no NUMBER,
    div_desc VARCHAR2(50),
    dept_detl dept_type);
         division_rec div_type;
    begin
    /*select count(*) into cnt_div from table(select div from organisation) d
    where d.id=1;*/
    for i_div in c_div
         loop
         exit when c_div%notfound;
         division_rec.div_no:=i_div.id;
         division_rec.div_desc:=i_div.divdesc;
         dbms_output.put_line('Division details = ' || division_rec.div_no || division_rec.div_desc);
    --end loop;
    /*select count(*) into cnt_dept from table(select dept from organisation) dp
    where dp.dept_div=i_div.id;*/
    for i_dept in c_dept
         loop
         exit when c_dept%notfound;
         select dp.id , dp.deptdesc
         into
         division_rec.dept_detl.dept_no, division_rec.dept_detl.dept_desc
         from
         table(select dept from organisation) dp
         where dp.dept_div=division_rec.div_no;
    -- division_rec.dept_detl.dept_no:=c_dept.id;
    -- division_rec.dept_detl.dept_desc:=c_dept.deptdesc;
         dbms_output.put_line('Department details = ' || division_rec.dept_detl.dept_no ||      division_rec.dept_detl.dept_desc);
    --end loop;
    /*select count(*) into cnt_cctr from table(select cctr from organisation ) cc
    where cc.cctr_dept=division_rec.dept_detl.dept_no;*/
         for i_cctr in c_cctr
              loop
              exit when c_cctr%notfound;
              select cc.id , cc.cctrdesc
              into
              division_rec.dept_detl.cctr_detl.cctr_no ,           division_rec.dept_detl.cctr_detl.cctr_desc
              from
              table(select cctr from organisation ) cc
              where cc.cctr_dept=division_rec.dept_detl.dept_no;
    -- division_rec.dept_detl.cctr_detl.cctr_no:=c_cctr.id;
    -- division_rec.dept_detl.cctr_detl.cctr_desc:=c_cctr.cctrdesc;
         dbms_output.put_line('Cost Center details = ' || division_rec.dept_detl.cctr_detl.cctr_no ||      division_rec.dept_detl.cctr_detl.cctr_desc);
    --end loop;
    /*select count(*) into c_oper from table(select oper from organisation) op
    where op.oper_cctr=division_rec.dept_detl.cctr_detl.cctr_no;*/
              for i_oper in c_oper
                   loop
                   exit when c_oper%notfound;
              select op.id , op.operdesc
              into
              division_rec.dept_detl.cctr_detl.oper_detl.oper_no,           division_rec.dept_detl.cctr_detl.oper_detl.oper_desc
              from
              table(select oper from organisation) op
              where op.oper_cctr=division_rec.dept_detl.cctr_detl.cctr_no;
    -- division_rec.dept_detl.cctr_detl.oper_detl.oper_no:=c_oper.id;
    -- division_rec.dept_detl.cctr_detl.oper_detl.oper_desc:=c_oper.operdesc;
         dbms_output.put_line('Operation details = ' || division_rec.dept_detl.cctr_detl.oper_detl.oper_no || division_rec.dept_detl.cctr_detl.oper_detl.oper_desc);
    end loop;
    end loop;
    end loop;
    end loop;
    end;
    declare
    ERROR at line 1:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at line 64
    I hope you might have the solutions.
    Thanks & Regards
    Nihar

Maybe you are looking for