Collect  giving error ORA 22814

getting ORA 22814 attribute or element value is larger than specified type.
TAB1(
item number(10)
item_id NVARCHAR2(250))
SELECT item, tab_to_nvarchar2(cast(collect(item_id order by item_id) as T_NVARCHAR2_TAB),',') as item_list
FROM TAB1
GROUP BY item
CREATE OR REPLACE TYPE T_NVARCHAR2_TAB AS TABLE OF NVARCHAR2 (4000);
CREATE OR REPLACE FUNCTION tab_to_nvarchar2 (p_nvarchar2_tab IN t_nvarchar2_tab, p_delimiter IN VARCHAR2 DEFAULT ',')
RETURN nvarchar2
IS
l_string NVARCHAR2 (32767) := NULL;
-- l_string VARCHAR2 (4000) := NULL;
BEGIN
FOR i IN REVERSE p_nvarchar2_tab.FIRST .. p_nvarchar2_tab.LAST
LOOP
IF i != p_nvarchar2_tab.LAST
THEN
l_string := p_delimiter || l_string;
END IF;
l_string := p_nvarchar2_tab (i) || l_string;
END LOOP;
RETURN l_string;
END tab_to_nvarchar2;

Collect will not work here. Use:
select  item,
        tab_to_nvarchar2(
                         cast(
                              multiset(
                                       select  item_id
                                         from  tab1 t2
                                         where t2.item = t1.item
                             as T_NVARCHAR2_TAB
                        ) item_list
  from  tab1 t1
  group by item
/For example:
SQL> CREATE OR REPLACE TYPE T_NVARCHAR2_TAB AS TABLE OF NVARCHAR2(4000)
  2  /
Type created.
SQL> CREATE OR REPLACE FUNCTION tab_to_nvarchar2 (p_nvarchar2_tab IN t_nvarchar2_tab, p_delimiter IN VARCHAR2 DEFAULT ',')
  2  RETURN nvarchar2
  3  IS
  4  l_string NVARCHAR2 (32767) := NULL;
  5  -- l_string VARCHAR2 (4000) := NULL;
  6  BEGIN
  7  FOR i IN REVERSE p_nvarchar2_tab.FIRST .. p_nvarchar2_tab.LAST
  8  LOOP
  9  IF i != p_nvarchar2_tab.LAST
10  THEN
11  l_string := p_delimiter || l_string;
12  END IF;
13  l_string := p_nvarchar2_tab(i) || l_string;
14  END LOOP;
15  RETURN l_string;
16  END tab_to_nvarchar2;
17  /
Function created.
SQL> select deptno,
  2         tab_to_nvarchar2(cast(collect(ename) as T_NVARCHAR2_TAB),',') as item_list
  3    from emp
  4    group by deptno
  5  /
       tab_to_nvarchar2(cast(collect(ename) as T_NVARCHAR2_TAB),',') as item_list
ERROR at line 2:
ORA-22814: attribute or element value is larger than specified in type
SQL> select  deptno,
  2          tab_to_nvarchar2(
  3                           cast(
  4                                multiset(
  5                                         select  ename
  6                                           from  emp e2
  7                                           where e2.deptno = e1.deptno
  8                                        )
  9                               as T_NVARCHAR2_TAB
10                              ),
11                           ','
12                          ) item_list
13    from  emp e1
14    group by deptno
15  /
DEPTNO ITEM_LIST
    30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
    20 SMITH,JONES,SCOTT,ADAMS,FORD
    10 CLARK,KING,MILLER
SQL>  But in general, scrap your code and use listagg (if you are on 11.2) or xmlagg:
SQL> select  deptno,
  2          listagg(ename,',') within group(order by ename) item_list
  3    from  emp
  4    group by deptno
  5  /
DEPTNO ITEM_LIST
    10 CLARK,KING,MILLER
    20 ADAMS,FORD,JONES,SCOTT,SMITH
    30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
SQL> select  deptno,
  2          rtrim(xmlagg(xmlelement(e,ename,',').extract('//text()')),',') item_list
  3    from  emp
  4    group by deptno
  5  /
DEPTNO ITEM_LIST
    10 CLARK,MILLER,KING
    20 JONES,FORD,ADAMS,SCOTT,SMITH
    30 BLAKE,JAMES,TURNER,MARTIN,WARD,ALLEN
SQL> SY.

Similar Messages

  • Refresh Collection Snapshots Error ORA-12008 ORA-01555

    Need some insight!
    Ct is implementing R12.1.1 ASCP using existing 11.5.10 EBS as source.
    In source EBS, when running Refresh Collection Snapshots (RCS) in COMPLETE mode, we encounter this error:
    ORA-12008: error in materialized view refresh path
    ORA-01555: snapshot too old: rollback segment number 13 with name "_SYSSMU13$" too small
    ORA-12008: error in materialized view refresh path
    ORA-01555: snapshot too old: rollback segment number 13 with name "_SYSSMU13$" too small
    All the snapshot entities got refreshed successfully (in 5 minutes) but the Refresh Collection Snapshot request itself ends with ERROR (after 4 hrs).
    Appreciate your input on this one.
    Thanks,
    Jake

    Welcome to the forums !
    ORA-01555 is a common error condition. There are typically two solutions (or a combination of both) -
    1. Increase rollback / undo tablespace size
    2. Run your process when the database is not active (i.e. few or no updates/deletes/inserts etc).
    More information may be available in these MOS Docs
    211121.1 - How To Run MSRFWOR - Refresh Collections Snapshots Concurrent Request From The Application
    207644.1 - Data Collections is Failing - All Errors - First Diagnostic Steps
    306418.1 - 11.5.10 MSRFWOR: Refresh Collection Snapshot Performance Is Poor and Fails with Errors
    369173.1 - MSRFWOR Refresh Collection Snapshots Performance Database Bug 4196039
    308487.1 - Refresh Collection Snapshot Request Fails Yet The Request Shows Complete Normal
    HTH
    Srini

  • Dynamic table in Oracle report data model using laxical parameter is giving error Ora-00936: missing expression

    Hi ,
    I am using Oracle report 10G
    And trying to create report with dynamic table
    SELECT &COL1, &COL2
    FROM &TAB
    If I put this on data model it gives below error
    ORA-00936: missing expression
    ==> from
    Can anybody advise to solve this issue.
    Regards,
    Brajesh

    Look in the Reports Builder Help:
    If you want to use lexical references in your SELECT clause, you should create a separate lexical reference for each column you will substitute. In addition, you should assign an alias to each lexical reference.
    Does adding the column alias solve the problem?

  • How to drop user giving error ORA-03113

    hello,
    I am trying to drop user as follows
    SQL> drop user jbponm_trf cascade;
    drop user jbponm_trf cascade
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    SQL>
    pls suggest me how to drop user.

    Hi Dear,
    Please reconnect from SYS and try again ,Looking there is some problem in your oracle connection or network problem.
    Best Regards
    Faheem latif
    Senior Database Architect
    Genie Technologies (Pvt.) Ltd.

  • 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.

  • From pl/sql table getting error - "ORA-01403: no data found"

    Hi All,
    i habe written package, and the spce define as -
    type F761RecType is RECORD (
    type F761TabType is TABLE of F761RecType INDEX BY BINARY_INTEGER;
    l_F761_table F761TabType;
    PROCEDURE modification1
    p_F761_table IN F761TabType,
    From button click of form i passed -
    DECLARE
    l_f761_table I743_PUC_MAPS_TREE_PKG.F761TabType;
    l_counter number;
    BEGIN
              LOOP
         l_counter :=l_counter+1;
              l_f761_table(l_counter).P_TABLE := :MAPS.P_table;
         EXIT WHEN      :SYSTEM.LAST_RECORD = 'TRUE' ;
    next_record;
    end loop;
    i743_puc_maps_tree_pkg.modification1(
                                            p_F761_table => l_f761_table,
    END;
    Now when I take table count (l_f761_table.count) in button click in form level I am getting value; but when I try to get the count in sid the package, it giving error "ORA-01403: no data found".
    Pls tell me where I am wrong ..!!
    BR,
    Subir

    Thaks all, probls has been solved..

  • Why this query is giving error in report

    I have a simple query ...
    SELECT &P_FLEXDATA C_FLEXDATA,
    CHART_OF_ACCOUNTS_ID C_NUM
    FROM GL_CODE_COMBINATIONS
    It is running fine in SQL prompt but when I create it as a report query then it is giving error: ORA-00904 "C_FLEXDATA": invalid identifier
    Please advise ....
    I shall be ever thankful...
    Best Regards

    Hello,
    You are using a "lexical" reference in the SQL query (&P_FLEXDATA).
    You must set a default value for P_FLEXDATA in order the SQL Query to be parsed successfuly
    Regards

  • BI Report Error:ORA-01476: divisor is equal to zero

    I have written the Query containing the Pl/SQL procedures and is working fine when executed ,but when I am using the same query for the BI Publisher report , in the Runtime the report is giving error *"ORA-01476: divisor is equal to zero"* .
    Please provide me with the answers and help ,as it is most important for me to get it solved.

    Hi,
    Try this...
    case when nvl(Y,0) = 0 then 0 else (X/Y) end
    Replace your columns in place of X and Y in your query..
    hope helps you....
    Cheers,
    Aravind

  • Appinfo node causes ORA-22814

    Hi All,
    I've got an error
    ORA-22814: attribute or element value is larger than specified in type
    ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 0
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 26
    ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 131
    ORA-06512: at "XDB.LOADXML", line 20
    when registering a shema with some <xs:appinfo source ="XXX"> node.
    When this node is completely commented out or part of the nodes inside it is commented out, everithing is fine.
    Is this a bug or a feature? Is there a limit on node size? If yes, is there some references?
    Any comments/suggestions are welcomed.
    Boris

    Sorry Mark,
    I was not specific enough about my appinfo node:
    It looks like this:
    <appinfo source="MyAppName">
    <SomeNodeName>
    <string>Some staff</string>
    <string>Some other staff</string>
    </SomeNodeName>
    <SomeOtherNodeName>
    <string>Some staff</string>
    <string>Some other staff</string>
    </SomeOtherNodeName>
    </appinfo>
    I'm using this node to put some hints for my app into schema. Because 'source' attribute contains my private name,
    I was assuming that the content of this node is nobody else business.
    XMLSpy validates this, so I'm assuming this
    is a valid aproach.
    So, the problem is not with the 'source' attribute, as you decided based on my incomplete post...
    To make things work I'm cutting some of <SomeOtherNodeName> nodes...
    The problem is in integral size of the whole <appinfo> node with all subnodes...
    So, the initial questions remains...
    Thank you for your replay,
    Boris

  • COLLECT into table of VARCHAR2 giving ORA-22814 error

    Hello,
    I am trying to collect a VARCHAR2(5 CHAR) column into a table type of VARCHAR2(5 CHAR) but it gives me the ORA-22814: attribute or element value is larger than specified in type.
    Even if I cast my string to this data type.
    SQL> CREATE OR REPLACE TYPE T_VARCHAR2_5_TAB AS TABLE OF VARCHAR2(5 CHAR);
      2  /
    Type created.
    SQL>
    SQL> DESC site_section_cours;
    Name                                      Null?    Type
    SEQ_SITE_COURS                            NOT NULL NUMBER
    CODE_SESSION                              NOT NULL VARCHAR2(6 CHAR)
    NUMERO_REFERENCE_SECTION_COURS            NOT NULL VARCHAR2(5 CHAR)
    CODE_STATUT_PUBLICATION_PDF               NOT NULL VARCHAR2(2 CHAR)
    CONTROLE_MODIFICATION                     NOT NULL NUMBER
    SEQ_BAREME_NOTES                                   NUMBER
    SQL>
    SQL> SELECT CAST(
      2              COLLECT(
      3              sisc.numero_reference_section_cours
      4              ORDER BY sisc.code_session, sisc.numero_reference_section_cours
      5              )
      6              AS t_varchar2_5_tab
      7           ) AS lov
      8  FROM   site_section_cours sisc;
              COLLECT(
    ERROR at line 2:
    ORA-22814: attribute or element value is larger than specified in type
    SQL>
    SQL> SELECT CAST(
      2              COLLECT(
      3              CAST(
      4                sisc.numero_reference_section_cours AS VARCHAR2 (5 CHAR)
      5              )
      6              ORDER BY sisc.code_session, sisc.numero_reference_section_cours
      7              )
      8              AS t_varchar2_5_tab
      9           ) AS lov
    10  FROM   site_section_cours sisc;
              COLLECT(
    ERROR at line 2:
    ORA-22814: attribute or element value is larger than specified in type What am I missing?
    Thanks
    Bruno

    A new test: try to collect into 10 and 20 char table type.
    Not working with 10 but working with 20.
    SQL> SELECT CAST(
      2              COLLECT(
      3              sisc.numero_reference_section_cours
      4              ORDER BY sisc.code_session, sisc.numero_reference_section_cours
      5              )
      6              AS t_varchar2_10_tab
      7           ) AS lov
      8  FROM   site_section_cours sisc;
              COLLECT(
    ERROR at line 2:
    ORA-22814: attribute or element value is larger than specified in type
    SQL>
    SQL> SELECT CAST(
      2              COLLECT(
      3              sisc.numero_reference_section_cours
      4              ORDER BY sisc.code_session, sisc.numero_reference_section_cours
      5              )
      6              AS t_varchar2_20_tab
      7           ) AS lov
      8  FROM   site_section_cours sisc;
    LOV                                                                            
    T_VARCHAR2_20_TAB('10001', '10003', '10004', '10016', '10018', '10019', '10020',
    '10022', '10025', '10028', '10029', '10030', '10031', '10032', '10039', '10040'
    , '10041', '10003', '21000', '21001', '21002', '21004', '21005', '21006', '21007
    ', '21008', '21009', '21010', '82001', '11972', '11986', '10018', '10019')      Bruno

  • Standard Data Collection Failing with Error ORA-04054: database link  does not exist.

    Hi Gurus,
    When I am running Standard Data Collection in ASCP(APS) instance R12.1.3, its failing with error : ORA-04054: database link  does not exist.
    There is no such Database link exits which is showing in above error.
    Also the database link name in the above error is not profile values in the database.
    I think, concurrent might be fetching this database link name  from some tables related to plan.
    I am not having much knowledge about how this ASCP/APS works.
    Need your help to resolve this issue.
    Thanks,

    Hi,
    ASCP Collections looks at the dblink from instances definitions from.
    1. Responsibility: Advanced Planning Administrator
    2. Navigation: Admin > Instances
    You may review the note in support.oracle.com - Understanding DB Links Setup for APS Applications - ASCP and ATP Functionality (Doc ID 813231.1)

  • Procedure giving error with collections

    H, i wrote a procedure in which i am using collections to out a some data.Its giving error. Below is format of procedure:
    Create or replace procabc(a in type_a, b in number, c out type_b)
    begin
    for i in 1....a.count loop
    for j in (select num from abc) loop
    if (num = 'condition1') then
    c(i) := num;
    elsif (num = 'condition2') then
    c(i) := num;
    elsif (num = 'condition3') then
    c(i) := num;
    else
    dbms_output.put_line('not matching');
    end if;
    end loop;
    end loop;
    end;
    In above code input a and output c are type which i had created.
    how to out my values in out parameter c...its executing ..i am getting print but its not storing in out parameter c which is type. what i need to do..even i had initialised the collection also tried c.event before storing..still wont work..can anyone help me???

    Megha Verma wrote:
    version is oracle 10g...i dont want to use cursors....You already are.
    for j in (select num from abc) loop
    1 loop is there because i am passing a array as input and i need all values from query whose output depends on that.You're passing an array, but you aren't using it anywhere!!!
    for i in 1....a.count loopa is not referenced in any subsequent code.
    second loop is to execute the query and get the data and store it in a collection. and return it to ut parameter...what i need to add values to my collection....Yes, and it's extremely inefficient (if it's even correct, seeing my previous comment about not using the collection you pass in anywhere).
    >
    c is out parameter and is a type(i had created).
    simply i want to know how to add values to it while i get my data when loop executes....it prints my valus...just tell how to add it to collections and return it as out parameter.Sadly it's not that simple. Simple to correct technically yes, but your entire process seems to be flawed so i really think you should revisit that. Or post sufficient information to have us help you in an actually helpful manner.

  • Error while trying to retrieve text for error ORA-12154

    Hello,
    I try to install php 5.1.2 on a WIN2003 server and IIS6 with the OCi8 extension without success from several days.
    On my server I've a 920 oracle client and the 10.1 instant client, I copy the tnsnames.ora in the instant client's directory.
    I've declare many environnement variables :
    - NLS_LANG : AMERICAN_AMERICA.WE8MSWIN1252
    - TNS_ADMIN : E:\...\oracle\instantclient_10_1
    - ORA_NLS33 : E:\..\oracle\920\ocommon\nls\ADMIN\DATA
    With the php command line the oci_connect function correctly works : the php command line use the instant client's tnsnames.ora. I can query with success my database.
    When I try to load a web php script (the same as the php command line script) I have the following error " Error while trying to retrieve text for error ORA-12154" ( oci_connect( $user , $pass, $sid ) . The $sid variable have the value of an alias declared in the tnsnames.ora.
    If I replace the sid's alias by something like this " (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xx.xx.xx.xx)(PORT=1521)))(CONNECT_DATA=(SID=xx)" in the oci_connect function, I have another error : Error while trying to retrieve text for error ORA-12705.
    A web page with the phpinfo function displays the following messages about oci8 extension : It seems to be correct.
    oci8
    OCI8 Support enabled
    Revision $Revision: 1.269.2.8 $
    Active Persistent Connections 0
    Active Connections 0
    Temporary Lob support enabled
    Collections support enabled
    Do you have any idea ? Thanks a lot

    The web server is not seeing the Oracle environment correctly. You need to set PATH to the instant client libraries. ORA_NLS33 is not used for Oracle 10g clients. Perhaps you have some library conflict with two versions of Oracle on the machine?
    These may help:
    http://www.oracle.com/technology/tech/php/htdocs/php_troubleshooting_faq.html#envvars
    http://blogs.oracle.com/opal/2006/05/01

  • Report error: ORA-06502: PL/SQL: numeric or value error: character string b

    I have a form which uses a customer form/report, drop downs etc..
    the debug shows it running this statement
    ...Execute Statement: begin begin SELECT distinct initcap(RTRIM (LTRIM (e.surname, ' *0123456789-/:.?,'), ' *0123456789-/:.?,') || ', ' || RTRIM (LTRIM (e.first_name, ' *0123456789-/:.?,'), ' *0123456789-/:.?,' )) empname, e.ID bulk collect into wwv_flow_utilities.g_display,wwv_flow_utilities.g_value FROM dms.dms_employees@dmsprd e, dms.dms_employee_contracts@dmsprd ec WHERE e.ID = ec.emp_id and e.surname like '%%' AND :p75_date BETWEEN ec.start_date AND NVL (ec.end_date, :p75_date) AND e.brh_id = 3654 ORDER BY 1; end; end;
    Then says
    "report error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small"
    Any Ideas?
    Thanks
    Dean

    Denes Kubicek wrote:
    A select list is limited in size. I am not sure what the limit is but that is definitelly the case.The maximum size for the HTML generated for a select list is 32K.
    86 options sounds on the low side to be hitting that limit, but there are other concerns to this as well. Scrolling through hundreds/thousands of options in a select list is a pain for users, and huge select lists produce bloated pages that impact load times and network bandwidth. That list of around 200 countries you find on many sites is about the sensible maximum length for a select list.
    You should use popups.Indeed.

  • Top N query giving error for oracle 8.0.6

    Dear All,
    We are executing this query SELECT XBLNR, WERKS, MATNR, MDV01, BACKFLQUANT, STATUS, SAPTIMESTAMP, PITSTIMESTAMP, PMTIMESTAMP, BATCH FROM (SELECT XBLNR, WERKS, MATNR, MDV01, BACKFLQUANT, STATUS, SAPTIMESTAMP, PITSTIMESTAMP, PMTIMESTAMP, BATCH FROM PMBPITS.PITS_UNITY WHERE STATUS = '01' ORDER BY PMTIMESTAMP) WHERE ROWNUM < 20
    on oracle 8.0.6 but this is giving the following error
    ora - 00907 missing right parenthesis error
    1. Is it that in the inner select we cannot use order by and where clause together.
    2. We also found that if we remove order by from inner select then the query is not giving error
    pls help . points will be awarded

    Hi,
    what ever the Aman said is correct. You check this is supported in 8.1.5, SQL allows you to embed the ORDER BY clause in a subquery and place the ROWNUM condition in the top-level query;
    'Top-N query' is a ORACLE 8i feature which is supported in SQL. However,
    Bug:855720 states the following:
    "PL/SQL does not support top-N queries (ORDER BY in SUBSELECT/SUBQUERY
    or VIEW. Since this feature is available in SQL, but not in PL/SQL,
    it has been logged as a Bug that will be fixed in 8.1.6."
    - Pavan Kumar N

Maybe you are looking for

  • Iphone 4 can't connect to itunes/app store

    I'm in need of some help!  I purchased an iphone 5s and i am giving my old iphone 4 to my son to use for games (wifi only). The iphone 4 has been reset and has the latest updated software installed. When i try to download games to it, it says can't c

  • Satellite L300 - Vista update error 8007007A

    I am using Toshiba L300 laptop with Windows Vista home premium loaded in the system while purchase. I found Vista Update through Windows update. I have tried to install it, but while installation i got a error message 8007007A. Can anyone help me to

  • XB270H DRIVER in Windows 8.1 Pro 64Bit Not Digitally assigned Will Not Load

    The drivers available that ACER have released are not being recognised by my system because the closest driver Windows 8 64Bit is not Digitally Assigned. So the Windows 8.1 Pro 64Bit sees the monitor as a GenericPnP only and so far have had no respon

  • No  Bars In field monitor

    The only way I can get to bars in the field monitor is by turning on blue button. Then blue only comes on when blue setting is clicked off. Making it nearly impossible to calibrate the field monitor. I am using Vista, but this problem only arose rece

  • Pipeline Delimeter issue in SSIS flatfile.

    I have flat file with pipeline delimeter with 9 columns, each columns having diffrent data lenth. i am having issue with one on of the column Address. User enter the value with PIPELINE symbol in his address, so that my developed SSIS packages got me