String Aggregation - ORA-01489

Hi, I am getting ORA-01489 for the following query. Basically, I am performing string aggregation:
SELECT LTRIM(REPLACE(sys_connect_by_path(expression, '::'), '::', ','),',')
INTO clob_variable
FROM (SELECT * FROM tb_metadata_detail WHERE performance_metadata_id = 2) TMD
WHERE connect_by_isleaf = 1
CONNECT BY performance_metadata_detail_id = PRIOR
performance_metadata_detail_id + 1
START WITH performance_metadata_detail_id = 1;
I heard to_clob can help. but where to put it?

I've got an idea:
Why don't you post some sample data which reproduce your problem? Instead of NO ROWS SELECTED
SQL> CREATE TABLE TB_METADATA_DETAIL
  2  (
  3  PERFORMANCE_METADATA_ID NUMBER,
  4  PERFORMANCE_METADATA_DETAIL_ID NUMBER,
  5  EXPRESSION CLOB,
  6  TARGET_COLUMN VARCHAR2(30 )
  7  );
Table created.
SQL>
SQL>
SQL> insert into TB_METADATA_DETAIL values (2, 1, 'SYSTEM_DATE', 'SYSTEM_DATE');
1 row created.
SQL> insert into TB_METADATA_DETAIL values (2, 2, 'LOAD_DATE'  , 'SYSDATE'    );
1 row created.
SQL>
SQL> commit;
Commit complete.
SQL>
SQL> SELECT LTRIM(REPLACE(sys_connect_by_path(expression, '::'), '::', ','),',')
  2  --INTO clob_variable
  3  FROM (SELECT * FROM tb_metadata_detail WHERE performance_metadata_id = 2) TMD
  4  WHERE connect_by_isleaf = 1
  5  CONNECT BY performance_metadata_detail_id = PRIOR performance_metadata_detail_id + 1
  6  START WITH performance_metadata_detail_id = 1;
no rows selected

Similar Messages

  • Connect by - sql help : getting error ORA-01489: result of string concatena

    here is an sql query and I am trying to cook a decode but since there are many columns invloved when I am trying to run this I am getting the following error:
    ORA-01489: result of string concatenation is too long
    Any kind of help is appreciated, I need to get this going otherwise I am dead :(
    Regards
    Rahul
    SQL:
    select sys_connect_by_path(c.decode_prep,'-') decode_prep
    from (select 'DECODE(BIAPPS_11.'||substr(b.all_cols,instr(b.all_cols,',',1,a.rn)+1,instr(b.all_cols,',',1,a.rn+1)-instr(b.all_cols,',',1,a.rn)-1)||','||'RAHULKALRA.'||substr(b.all_cols,instr(b.all_cols,',',1,a.rn)+1,instr(b.all_cols,',',1,a.rn+1)-instr(b.all_cols,',',1,a.rn)-1)||',''1'',''0'')' decode_prep, rownum curr, rownum -1 prev
    from (select rownum rn
    from dual connect by rownum <=
    (select (length('ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM')
    - length(replace('ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM',',')))+1 total_cols
    from dual)) a, (select ','||'ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM'||',' all_cols from dual) b) c
    start with curr = 1
    connect by prior curr = prev
    order by length(sys_connect_by_path(c.decode_prep,'-')) desc
    same as above sql only difference is here I am pulling the first record from the result set which above query returns :
    select ltrim(replace(decode_prep,'-','||'),'||') decode_prep
    from (select sys_connect_by_path(c.decode_prep,'-') decode_prep
    from (select 'DECODE(BIAPPS_11.'||substr(b.all_cols,instr(b.all_cols,',',1,a.rn)+1,instr(b.all_cols,',',1,a.rn+1)-instr(b.all_cols,',',1,a.rn)-1)||','||'RAHULKALRA.'||substr(b.all_cols,instr(b.all_cols,',',1,a.rn)+1,instr(b.all_cols,',',1,a.rn+1)-instr(b.all_cols,',',1,a.rn)-1)||',''1'',''0'')' decode_prep, rownum curr, rownum -1 prev
    from (select rownum rn
    from dual connect by rownum <=
    (select (length('ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM')
    - length(replace('ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM',',')))+1 total_cols
    from dual)) a, (select ','||'ROW_WID,COST_CENTER_NUM,COST_CENTER_NAME,COST_CENTER_DESC,CONTROL_AREA_NUM,CONTROL_AREA_NAME,CATEGORY_CODE,CATEGORY_NAME,CATEGORY_DESC,MANAGER_NAME,CURRENCY_CODE,CURRENCY_NAME,LANGUAGE_CODE,LANGUAGE_NAME,ST_ADDRESS1,ST_ADDRESS2,POST_OFFICE_BOX,CITY_NAME,STATE_CODE,STATE_NAME,REGION_CODE,REGION_NAME,COUNTRY_CODE,COUNTRY_NAME,POSTAL_CODE,PHONE_NUM,FAX_NUM,CSCN_HIER1_CODE,CSCN_HIER1_NAME,CSCN_HIER2_CODE,CSCN_HIER2_NAME,CSCN_HIER3_CODE,CSCN_HIER3_NAME,CSCN_HIER4_CODE,CSCN_HIER4_NAME,CSCN_HIER5_CODE,CSCN_HIER5_NAME,CSCN_HIER6_CODE,CSCN_HIER6_NAME,ACTIVE_FLG,CREATED_BY_WID,CHANGED_BY_WID,CREATED_ON_DT,CHANGED_ON_DT,AUX1_CHANGED_ON_DT,AUX2_CHANGED_ON_DT,AUX3_CHANGED_ON_DT,AUX4_CHANGED_ON_DT,SRC_EFF_FROM_DT,SRC_EFF_TO_DT,EFFECTIVE_FROM_DT,EFFECTIVE_TO_DT,DELETE_FLG,CURRENT_FLG,W_INSERT_DT,W_UPDATE_DT,DATASOURCE_NUM_ID,ETL_PROC_WID,INTEGRATION_ID,SET_ID,TENANT_ID,X_CUSTOM'||',' all_cols from dual) b) c
    start with curr = 1
    connect by prior curr = prev
    order by length(sys_connect_by_path(c.decode_prep,'-')) desc)
    where rownum = 1
    Edited by: Mac_Freak_Rahul on Nov 28, 2012 1:31 AM : in the first sql ')'
    removed after desc in the last line so now this query will run and throw an error.

    Clearly your error is because the string concatenation you are doing with sys_connect_by_path is exceeding the 4000 bytes permitted by SQL.
    In that case you need to concatenate your data into a CLOB datatype, for which you'll need a CLOB aggregation function...
    create or replace type clobagg_type as object
      text clob,
      static function ODCIAggregateInitialize(sctx in out clobagg_type) return number,
      member function ODCIAggregateIterate(self in out clobagg_type, value in clob) return number,
      member function ODCIAggregateTerminate(self in clobagg_type, returnvalue out clob, flags in number) return number,
      member function ODCIAggregateMerge(self in out clobagg_type, ctx2 in clobagg_type) return number
    create or replace type body clobagg_type is
      static function ODCIAggregateInitialize(sctx in out clobagg_type) return number is
      begin
        sctx := clobagg_type(null) ;
        return ODCIConst.Success ;
      end;
      member function ODCIAggregateIterate(self in out clobagg_type, value in clob) return number is
      begin
        self.text := self.text || value ;
        return ODCIConst.Success;
      end;
      member function ODCIAggregateTerminate(self in clobagg_type, returnvalue out clob, flags in number) return number is
      begin
        returnValue := self.text;
        return ODCIConst.Success;
      end;
      member function ODCIAggregateMerge(self in out clobagg_type, ctx2 in clobagg_type) return number is
      begin
        self.text := self.text || ctx2.text;
        return ODCIConst.Success;
      end;
    end;
    create or replace function clobagg(input clob) return clob
      deterministic
      parallel_enable
      aggregate using clobagg_type;
    SQL> select trim(',' from clobagg(ename||',')) as enames from emp;
    ENAMES
    SMITH,ALLEN,WARD,JONES,MARTIN,BLAKE,CLARK,SCOTT,KING,TURNER,ADAMS,JAMES,FORD,MILLER
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (select 'PFL' c1, 0 c2,110 c3 from dual union all
      3     select 'LHL', 0 ,111 from dual union all
      4     select 'PHL', 1, 111 from dual union all
      5     select 'CHL', 2, 111 from dual union all
      6     select 'DHL', 0, 112 from dual union all
      7     select 'VHL', 1, 112 from dual union all
      8     select 'CPHL', 0, 114 from dual union all
      9     select 'WDCL', 1, 114 from dual union all
    10     select 'AHL' ,2 ,114 from dual union all
    11     select 'NFDL', 3, 114 from dual)
    12  --
    13  -- end of test data
    14  --
    15  select trim(clobagg(c1||' ')) as c1, c3
    16  from (select * from t order by c3, c2)
    17  group by c3
    18* order by c3
    SQL> /
    C1                                     C3
    PFL                                   110
    LHL CHL PHL                           111
    DHL VHL                               112
    CPHL AHL NFDL WDCL                    114

  • Ora-01489: result of string concatenation is too long

    Hello Gurus,
    i have a typical problem
    i am constructing a query in FORM and writing SQLPLUS script into a .SQL file. file will contain final data like below..
    set linesize 90
    set pagesize 0
    set echo off
    set verify off
    set termout off
    set feedback off
    set trimspool on
    set escape '^'
    spool D:\10GAPPServerappln\xxx\TEMPREP\ADA39057.sql;
    set linesize 229
    select ' IQIS# ,Cust Complaint Short Txt ,CD Short Txt ' from dual;
    set linesize 129
    select a||','||b||','||c||d from table;
    spool off;
    exit;
    After this By using HOST command i will execute the above .sql script and will write the output to text file.
    But problem is when i have clob column in any one of concatenated columns in query (a or b or c) then i am getting the error "Ora-01489: result of string concatenation is too long".
    pls suggest me how to overcome this problem..

    sybrand_b wrote:
    Obviously the || operator is concatenating strings, your CLOB is implicitly converted to a VARCHAR2, which has a 4000 bytes limit.???
    From non-experts who did read documentation:
    CLOB || VARCHAR2 = CLOB:
    SQL> CREATE OR REPLACE
      2  VIEW V1
      3  AS SELECT TO_CLOB('A') || 'A' clob_concat_varchar2 FROM dual
      4  /
    View created.
    SQL> DESC V1
    Name                                      Null?    Type
    CLOB_CONCAT_VARCHAR2                               CLOB
    SQL> SY.

  • ORA-01489 Received Generating SQL for Report Region

    I am new to Apex and I am running into an issue with an report region I am puzzled by. Just a foreword, I'm sure this hack solution will get a good share of facepalms and chuckles from those with far more experience. I welcome suggestions and criticism that are helpful and edifying!
    I am on Apex 4.0.2.00.07 running on 10g, I believe R2.
    A little background, my customer has asked an Excel spreadsheet be converted into a database application. As part of the transition they would like an export from the database that is in the same format as the current spreadsheet. Because the column count in this export is dynmic based on the number of records in a specific table, I decided to create a temporary table for the export. The column names in this temp table are based on a "name" column from the same data table so I end up with columns named 'REC_NAME A', 'REC_NAME B', etc. (e.g. Alpha Record, Papa Record, Echo Record, X-Ray Record). The column count is currently ~350 for the spreadsheet version.
    Because the column count is so large and the column names are dynamic I've run into a host of challenges and errors creating this export. I am a contractor in a corporate environmentm, so making changes to the apex environment or installation is beyond my influence and really beyond what could be justified by this single requirement for this project. I have tried procedures and apex plug-ins for generating the file however the UTL_FILE package is not available to me. I am currently generating the SQL for the query in a function and returning it to the report region in a single column (the user will be doing a text-to-column conversion later). The data is successfully being generated, however, the sql for the headers is where I am stumped.
    At first I thought it was because I returned both queries as one and they were joined with a 'union all'. However, after looking closer, the SQL being returned for the headers is about +10K+ characters long. The SQL being returned for the data is about +14k+. As mentioned above, the data is being generated and exported, however when I generate the SQL for the headers I am receiving a report error with "ORA-01489: result of string concatenation is too long" in the file. I am puzzled why a shorter string is generating this message. I took the function from both pages and ran them in a SQL command prompt and both return their string values without errors.
    I'm hopeful that it's something obvious and noobish that I'm overlooking.
    here is the code:
    data SQL function:
    declare
      l_tbl varchar2(20);
      l_ret varchar2(32767);
      l_c number := 0;
      l_dlim varchar2(3) := '''|''';
    begin
      l_tbl := 'EXPORT_STEP';
      l_ret := 'select ';
      for rec in (select column_name from user_tab_columns where table_name = l_tbl order by column_id)
      loop
        if l_c = 1 then
            l_ret := l_ret || '||' || l_dlim || '|| to_char("'||rec.column_name||'")';
        else
            l_c := 1;
            l_ret := l_ret || ' to_char("' || rec.column_name || '")';
        end if;
      end loop;
        l_ret := l_ret || ' from ' || l_tbl;
      dbms_output.put_line(l_ret);
    end;header sql function:
    declare
      l_tbl varchar2(20);
      l_ret varchar2(32767);
      l_c number := 0;
      l_dlim varchar2(3) := '''|''';
    begin
      l_tbl := 'EXPORT_STEP';
      for rec in (select column_name from user_tab_columns where table_name = l_tbl order by column_id)
      loop
        if l_c = 1 then
            l_ret := l_ret || '||' || l_dlim || '||'''||rec.column_name||'''';
        else
            l_c := 1;
            l_ret := l_ret || '''' || rec.column_name || '''';
        end if;
      end loop;
        l_ret := l_ret || ' from dual';
      dbms_output.put_line(l_ret);
    end;-------
    EDIT: just a comment on the complexity of this export, each record in the back-end table adds 12 columns to my export table. Those 12 columns are coming from 5 different tables and are the product of a set of functions calculating or looking up their values. This is export is really a pivot table based on the records in another table.
    Edited by: nimda xinu on Mar 8, 2013 1:28 PM

    Thank you, Denes, for looking into my issue. I appreciate your time!
    It is unfortunately a business requirement. My customer has required that the data we are migrating to this app from a spreadsheet be exported in the same format, albeit temporarily. I still must meet the requirement. I'm working around the 350 columns by dumping everything into a single column, which is working for the data, however, the headers export is throwing the 01489 error. I did run into the error you posted in your reply. I attempted to work around it with the clob type but eneded up running into my string concatentation error again.
    I'm open to any suggestions at this point given that I have the data. I'm so close because the data is exporting, but because the columns are dynamic, the export does me little good without the headers to go along with it.

  • SQL command running into error: ora-01489

    Hello everyone,
    i have created a query as shown below. When i am trying to run this query on test server using TOAD it executes without any error.
    The same query i am trying to copy and paste on TOAD for my production server and it gives me an error:
    ORA-01489: result of string concatenation is too long
    select payslip_of_month,
    person_id, payslip_date, element_name,
    pay_action, business_group_id, payroll_desc,payment_currency,LISTAGG(screen_entry_value, ' ') WITHIN GROUP (ORDER BY display_sequence) AS ENTRIES_RESULT
    from (
    SELECT piv.display_sequence,piv.input_value_id,TO_CHAR (pact.effective_date, 'Month RRRR') payslip_of_month,
    per.person_id person_id,
    CASE
    WHEN pact.action_type <> 'Q'
    THEN TO_CHAR (pact.effective_date,'DD-MON-RRRR')
    ELSE TO_CHAR (NVL (pact.pay_advice_date, pact.DATE_EARNED),'DD-MON-RRRR')
    END payslip_date,
    NVL (pettl.reporting_name, pettl.element_name) element_name,
    trim(peev.screen_entry_value) screen_entry_value,pact.action_type pay_action, per.business_group_id,
    CASE
    WHEN has.assignment_set_name LIKE '%MAINRUN%'
    THEN 'End of Month Payment'
    WHEN pact.action_type = 'Q'
    THEN 'Request Payment'
    ELSE 'Adjustment Payment'
    END payroll_desc,
    pet.output_currency_code payment_currency
    FROM pay_element_types_f_tl pettl,
    pay_element_classifications_tl pectl,
    pay_element_types_f pet,
    pay_element_classifications pec,
    pay_input_values_f piv,
    pay_assignment_actions asact,
    pay_payroll_actions pact,
    per_abs_attendance_types_v ABS,
    per_all_assignments_f ass,
    per_all_people_f per,
    fnd_lookup_values fnd,
    hr_assignment_sets has ,
    pay_element_entry_values_f peev
    WHERE pectl.classification_id = pec.classification_id
    AND pectl.LANGUAGE = USERENV ('LANG')
    AND pettl.element_type_id = pet.element_type_id
    AND pettl.LANGUAGE = USERENV ('LANG')
    AND pact.payroll_action_id = asact.payroll_action_id
    AND pet.classification_id = pec.classification_id
    AND piv.element_type_id = pet.element_type_id
    AND piv.element_type_id = ABS.element_type_id(+)
    AND asact.assignment_id = ass.assignment_id
    AND ass.person_id = per.person_id
    and piv.name in ('Remarks1')
    AND SYSDATE BETWEEN ass.effective_start_date AND ass.effective_end_date
    AND SYSDATE BETWEEN per.effective_start_date AND per.effective_end_date
    AND pact.effective_date BETWEEN piv.effective_start_date
    AND piv.effective_end_date
    AND pact.effective_date BETWEEN pet.effective_start_date
    AND pet.effective_end_date
    AND fnd.lookup_code = pact.action_type
    AND fnd.lookup_type = 'ACTION_TYPE'
    AND pact.assignment_set_id = has.assignment_set_id(+)
    AND pettl.element_name = 'Payslip Remarks'
    and piv.input_value_id =peev.input_value_id
    and pact.effective_date between peev.EFFECTIVE_START_DATE and peev.EFFECTIVE_END_DATE
    order by piv.display_sequence)
    where PERSON_ID=:per_id
    and PAYSLIP_DATE like '%APR%2013%'
    and BUSINESS_GROUP_ID=0
    group by payslip_of_month, person_id, payslip_date, element_name,pay_action, business_group_id, payroll_desc,payment_currency
    Strange! I am unable to understand that the data entry done on both servers is same yet on one server it works fine however on the production server it fails.
    Pls help.
    thnx

    Hallo,
    you can replace the listagg command with screen_entry_value only and see if the data set is the same.
    regards
    Giuseppe

  • ORA-01489 sys_connect_by_path and previous solution not working

    Hi all.
    Oracle version:
    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 Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    I need to get routes in a map and the associated sum of distances from some point to another.
    map
    --     9
      F ----------E
      | \         |
      |  \2       |6
      |   \   11  |
    14|   C-------D
      |  / \10   /
      | /9  \   /15
      |/     \ /
      A-------B
         7I have a query that correctly gets the routes.
    WITH distances AS
         SELECT 'A' n1, 'B' n2, 7 d FROM DUAL UNION
         SELECT 'A' n1, 'C' n2, 9 d FROM DUAL UNION
         SELECT 'A' n1, 'F' n2, 14 d FROM DUAL UNION
         SELECT 'B' n1, 'D' n2, 15 d FROM DUAL UNION
         SELECT 'B' n1, 'C' n2, 10 d FROM DUAL UNION
         SELECT 'C' n1, 'D' n2, 11 d FROM DUAL UNION
         SELECT 'C' n1, 'F' n2, 2 d FROM DUAL UNION
         SELECT 'D' n1, 'E' n2, 6 d FROM DUAL UNION
         SELECT 'F' n1, 'E' n2, 9 d FROM DUAL
    SELECT
         'A'||sys_connect_by_path(n2,'-') path,
         SUBSTR(sys_connect_by_path(d,'+'),2) sum_dist
    FROM distances
    START WITH n1='A'
    CONNECT BY NOCYCLE PRIOR n2=n1;
    A-B          7
    A-B-C          7+10
    A-B-C-D          7+10+11
    A-B-C-D-E     7+10+11+6
    A-B-C-F          7+10+2
    A-B-C-F-E     7+10+2+9
    A-B-D          7+15
    A-B-D-E          7+15+6
    A-C          9
    A-C-D          9+11
    A-C-D-E          9+11+6
    A-C-F          9+2
    A-C-F-E          9+2+9
    A-F          14
    A-F-E          14+9The problem is when there are a lot of nodes, I get an ORA-01489: result of string concatenation is too long.
    I followed this link.
    sys_connect_by_path & to_CLOB
    I built the specified package but apparently is combining elements.
    If it's called just one time.
    WITH distances AS
         SELECT 'A' n1, 'B' n2, 7 d FROM DUAL UNION
         SELECT 'A' n1, 'C' n2, 9 d FROM DUAL UNION
         SELECT 'A' n1, 'F' n2, 14 d FROM DUAL UNION
         SELECT 'B' n1, 'D' n2, 15 d FROM DUAL UNION
         SELECT 'B' n1, 'C' n2, 10 d FROM DUAL UNION
         SELECT 'C' n1, 'D' n2, 11 d FROM DUAL UNION
         SELECT 'C' n1, 'F' n2, 2 d FROM DUAL UNION
         SELECT 'D' n1, 'E' n2, 6 d FROM DUAL UNION
         SELECT 'F' n1, 'E' n2, 9 d FROM DUAL
    SELECT
         'A'||'-'||hierarchy.branch(LEVEL,n2,'-') path
    FROM distances
    START WITH n1='A'
    CONNECT BY NOCYCLE PRIOR n2=n1;
    A-B
    A-B-C
    A-B-C-D
    A-B-C-D-E
    A-B-C-F
    A-B-C-F-E
    A-B-D
    A-B-D-E
    A-C
    A-C-D
    A-C-D-E
    A-C-F
    A-C-F-E
    A-FBut if I call it twice in the same query...
    WITH distances AS
         SELECT 'A' n1, 'B' n2, 7 d FROM DUAL UNION
         SELECT 'A' n1, 'C' n2, 9 d FROM DUAL UNION
         SELECT 'A' n1, 'F' n2, 14 d FROM DUAL UNION
         SELECT 'B' n1, 'D' n2, 15 d FROM DUAL UNION
         SELECT 'B' n1, 'C' n2, 10 d FROM DUAL UNION
         SELECT 'C' n1, 'D' n2, 11 d FROM DUAL UNION
         SELECT 'C' n1, 'F' n2, 2 d FROM DUAL UNION
         SELECT 'D' n1, 'E' n2, 6 d FROM DUAL UNION
         SELECT 'F' n1, 'E' n2, 9 d FROM DUAL
    SELECT
         'A'||SUBSTR(hierarchy.branch(LEVEL,n2,'-'),2) path,
         hierarchy.branch(LEVEL,d,'+') sum_dist
    FROM distances
    START WITH n1='A'
    CONNECT BY NOCYCLE PRIOR n2=n1;
    A          7
    A-C          7+10
    A-10-D          7+10+11
    A-10-11-E     7+10+11+6
    A-10-F          7+10+2
    A-10-2-E     7+10+2+9
    A-D          7+15
    A-15-E          7+15+6
    A          9
    A-D          9+11
    A-11-E          9+11+6
    A-F          9+2
    A-2-E          9+2+9As you can see, is combining the elements (A-10-11-E) node - distance - distance - node
    Do I have to create separate functions in the package, one per column?, or is there another way to solve this problem?, or even better, another way to solve the original problem (ORA-01489)
    Thanks a lot.
    Regards.
    Package code (by Solomon Yakobson):
    CREATE OR REPLACE
      PACKAGE Hierarchy
        IS
            TYPE BranchTableVarchar2Type IS TABLE OF VARCHAR2(4000)
              INDEX BY BINARY_INTEGER;
            BranchTableVarchar2 BranchTableVarchar2Type;
            TYPE BranchTableClobType IS TABLE OF CLOB
              INDEX BY BINARY_INTEGER;
            BranchTableClob BranchTableClobType;
            FUNCTION Branch(
                            p_Level          IN NUMBER,
                            p_Value          IN VARCHAR2,
                            p_Delimiter      IN VARCHAR2 DEFAULT CHR(0)
              RETURN VARCHAR2;
            PRAGMA RESTRICT_REFERENCES(Branch,WNDS);
            FUNCTION Branch(
                            p_Level          IN NUMBER,
                            p_Value          IN CLOB,
                            p_Delimiter      IN VARCHAR2 DEFAULT CHR(0)
              RETURN CLOB;
            PRAGMA RESTRICT_REFERENCES(Branch,WNDS);
    END Hierarchy;
    CREATE OR REPLACE
      PACKAGE BODY Hierarchy
        IS
            ReturnValueVarchar2 VARCHAR2(4000);
            ReturnValueClob     CLOB;
        FUNCTION Branch(
                        p_Level        IN NUMBER,
                        p_Value        IN VARCHAR2,
                        p_Delimiter    IN VARCHAR2 DEFAULT CHR(0)
          RETURN VARCHAR2
          IS
          BEGIN
              BranchTableVarchar2(p_Level) := p_Value;
              ReturnValueVarchar2          := p_Value;
              FOR I IN REVERSE 1..p_Level - 1 LOOP
                ReturnValueVarchar2 := BranchTableVarchar2(I)|| p_Delimiter || ReturnValueVarchar2;
              END LOOP;
              RETURN ReturnValueVarchar2;
        END Branch;
        FUNCTION Branch(
                        p_Level        IN NUMBER,
                        p_Value        IN CLOB,
                        p_Delimiter    IN VARCHAR2 DEFAULT CHR(0)
          RETURN CLOB
          IS
          BEGIN
              BranchTableClob(p_Level) := p_Value;
              ReturnValueClob          := p_Value;
              FOR I IN REVERSE 1..p_Level - 1 LOOP
                ReturnValueClob := BranchTableClob(I)|| p_Delimiter || ReturnValueClob;
              END LOOP;
              RETURN ReturnValueClob;
        END Branch;
    END Hierarchy;
    /Edited by: sKr on 08-mar-2012 17:29
    Package code added

    Hi,
    sKr wrote:
    Hi all.
    Oracle version:
    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 Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    I need to get routes in a map and the associated sum of distances from some point to another.
    map
    --     9
    F ----------E
    | \         |
    |  \2       |6
    |   \   11  |
    14|   C-------D
    |  / \10   /
    | /9  \   /15
    |/     \ /
    A-------B
    7... I wish we could mark questions as "Helpful" or "Correct". You'd get 10 points for sure.
    Do I have to create separate functions in the package, one per column?,You don't need separate functions. One user-defined function should be enough, just like one built-in version of SYS_CONNECT_BY_PATH is enough. Whatever it has to store internally, it knows to keep a separate copy for every argument that you call it with. The problem with the package, as originally posted, is that there's only one internal variable BranchTableVarchar2. Instead of one variable, make an array of similar variables, and add an optional argument to the branch funtion to tell it which element in that array to use.
    CREATE OR REPLACE
      PACKAGE Hierarchy
        IS
            TYPE BranchTableVarchar2Type IS TABLE OF VARCHAR2(4000)
              INDEX BY BINARY_INTEGER;
            BranchTableVarchar2 BranchTableVarchar2Type;
         TYPE VList     IS TABLE OF BranchTableVarchar2Type          -- ***  NEW  ***
           INDEX BY     BINARY_INTEGER;                         -- ***  NEW  ***
         vl     VList;                                      -- ***  NEW  ***
            TYPE BranchTableClobType IS TABLE OF CLOB
              INDEX BY BINARY_INTEGER;
            BranchTableClob BranchTableClobType;
            FUNCTION Branch(
                            p_Level          IN NUMBER,
                            p_Value          IN VARCHAR2,
                            p_Delimiter      IN VARCHAR2     DEFAULT CHR(0),
                   p_PathNum      IN PLS_INTEGER     DEFAULT     1     -- ***  NEW  ***
              RETURN VARCHAR2;
            PRAGMA RESTRICT_REFERENCES(Branch,WNDS);
            FUNCTION Branch(
                            p_Level          IN NUMBER,
                            p_Value          IN CLOB,
                            p_Delimiter      IN VARCHAR2 DEFAULT CHR(0)
              RETURN CLOB;
            PRAGMA RESTRICT_REFERENCES(Branch,WNDS);
    END Hierarchy;
    SHOW ERRORS
    PROMPT     ==========  FK BODY  ==========
    CREATE OR REPLACE
      PACKAGE BODY Hierarchy
        IS
            ReturnValueVarchar2 VARCHAR2(4000);
            ReturnValueClob     CLOB;
        FUNCTION Branch(
                        p_Level        IN NUMBER,
                        p_Value        IN VARCHAR2,
                        p_Delimiter    IN VARCHAR2       DEFAULT CHR(0),
                  p_PathNum        IN PLS_INTEGER DEFAULT 1     -- ***  NEW  ***
          RETURN VARCHAR2
          IS
          BEGIN
              vl (p_PathNum) (p_Level) := p_Value;               -- ***  CHANGED  ***
              ReturnValueVarchar2          := p_Value;
              FOR I IN REVERSE 1..p_Level - 1 LOOP
                ReturnValueVarchar2 := vl (p_PathNum) (I)          -- ***  CHANGED  ***
                             || p_Delimiter
                         || ReturnValueVarchar2;
              END LOOP;
              RETURN ReturnValueVarchar2;
        END Branch;
        FUNCTION Branch(
                        p_Level        IN NUMBER,
                        p_Value        IN CLOB,
                        p_Delimiter    IN VARCHAR2 DEFAULT CHR(0)
          RETURN CLOB
          IS
          BEGIN
              BranchTableClob(p_Level) := p_Value;
              ReturnValueClob          := p_Value;
              FOR I IN REVERSE 1..p_Level - 1 LOOP
                ReturnValueClob := BranchTableClob(I)|| p_Delimiter || ReturnValueClob;
              END LOOP;
              RETURN ReturnValueClob;
        END Branch;
    END Hierarchy;
    SHOW ERRORSAs you can see, I only changed the VARCHAR2 version. I'll leave changing the CLOB version as an exercise for you.
    When you call branch, pass a unique number for each column of output. If you don't explicitly give a number, it will default to 0.
    Here's your query modified to call it:
    SELECT  'A' || SUBSTR ( hierarchy.branch ( LEVEL
                                           , n2
                    , 2
                    )          AS path
    ,     hierarchy.branch ( LEVEL
                    , d
                    , '+'
                    , 12
                    )     AS sum_dist
    FROM    distances
    START WITH          n1 = 'A'
    CONNECT BY NOCYCLE      PRIOR n2     = n1
    ;For path, I called branch with only 3 arguments, so it's using vl (0) for internal storage for path.
    For sum_dist, I had to use a different integer. I couldn't decide if I should use 1 or 2, so I compromised and used 12. I could have used any integer, except 0.
    Output:
    PATH                           SUM_DIST
    A                              7
    A-C                            7+10
    A-C-D                          7+10+11
    A-C-D-E                        7+10+11+6
    A-C-F                          7+10+2
    A-C-F-E                        7+10+2+9
    A-D                            7+15
    A-D-E                          7+15+6
    A                              9
    A-D                            9+11
    A-D-E                          9+11+6
    A-F                            9+2
    A-F-E                          9+2+9
    A                              14
    A-E                            14+9
    or is there another way to solve this problem?, or even better, another way to solve the original problem (ORA-01489)Since you're calling a user-defined package, you might want to add other features to the package.
    For starters, in addition to a function that returns a string like '7+10+11', it might be handy to have a string that keeps those numbers internally, but returns the actual value 7 + 10 + 11 = 28.
    If you're using this for problems where you want to find the path with the least total d (or the greatest total d, for that matter, but for now let's say you're only interested in the minimum), you might want a function that keeps track of the minimum total d encountered so far for each node. Every time you find a different path to a node, the function could check to see if the total d is better than the previous best. If not, it could return a flag (sort of like CONNECT_BY_ISCYCLE) that tells you not to bother with that path any more.

  • String aggregation

    I have a problem with string aggregation. Please take a look at below.
    SQL> select * from a
      2  /
    INTERFACE  INBOX
    IF0001     something
    IF0002     something2
    SQL>
    SQL> select * from b
      2  /
    INTERFACE  FILENAME
    IF0001     file1
    IF0001     file2
    IF0001     file3
    IF0002     -
    SQL> Can I have a solution for output like this?
    INTERFACE  INBOX       FILENAME
    IF0001     something   file1|file2|file3
    IF0002     something2  -I've tried many things like
    SQL> select b1.interface, sys_connect_by_path(b1.filename, '|')
      2  from (select b.*, rownum rn
      3        from b) b1
      4  start with b1.rn = 1
      5  connect by b1.interface = prior b1.interface
      6  /
    ERROR:
    ORA-01436: CONNECT BY loop in user data
    no rows selectedI have even seen the string aggregation from oracle-base.com. I couldn't get to my problem with this.
    You can use the following for your testing.
    drop table A
    drop table B
    create table A(interface varchar2(10), inbox varchar2(10))
    create table B(interface varchar2(10), filename varchar2(10))
    insert into A values('IF0001','something');
    insert into A values('IF0002','something2');
    insert into B values('IF0001','file1');
    insert into B values('IF0001','file2');
    insert into B values('IF0001','file3');
    insert into B values('IF0002','-');
    commit
    /If I can't get a solution in SQL, then I will go for a user defined function. But, I know you guys can help me out. Solutions are highly appreciated and anyone in Holland can even anticipate a beer(Heineken).
    Cheers
    Sarma.

    Hi I am using this code and getting following output :
    SQL> SELECT MAX(SYS_CONNECT_BY_PATH(hdg_id,',')) as result
    2 FROM (
    3 SELECT lstng_id, hdg_id, ROW_NUMBER() OVER (ORDER BY lstng_id,hdg_id asc ) AS rn
    4 FROM dpc.dpc_ldh
    5 )
    6 START WITH rn = 1
    7 CONNECT BY PRIOR rn = rn - 1 AND PRIOR lstng_id = lstng_id;
    RESULT
    ,100,504,508,508,4947
    But I want like :
    ListingId HdgId
    a 100
    a 504
    a 508
    a 508
    a 4947
    ListingId HdgId
    a 100,504,508,508,4947

  • SQL string aggregation

    Hai all
    I am using the below Collection fucntion for string aggregation.
    Its giving values in correct way but giving duplicates too based on my data.. How can I eliminate duplicates?
    For example:
    Instead of this
    10 CLARK,KING,MILLER
    It gives me
    10 CLARK,KING,MILLER, CLARK,KING,MILLER
    [http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php#collect]
    Thanks

    user4552416 wrote:
    I am using 10G.
    Data is like this
    A1 B1 C1
    A1 B2 C2
    A1 B1 C3
    A2 B3 C4
    I should get data like this
    A1 B1,B2 C1,C2,C3
    A2 B3 C4
    But I am getting something like this
    A1 B1,B2,B1,B2 C1,C2,C3,C1,C2,C3
    A2 B3 C4
    ThanksSomething like this then...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'A1' as a, 'B1' as b, 'C1' as c from dual union all
      2             select 'A1', 'B2', 'C2' from dual union all
      3             select 'A1', 'B1', 'C3' from dual union all
      4             select 'A2', 'B3', 'C4' from dual)
      5  --
      6  -- END OF TEST DATA
      7  --
      8  select a
      9        ,trim(',' from sys_connect_by_path(b,',')) as b
    10        ,trim(',' from sys_connect_by_path(c,',')) as c
    11  from (select a,b,c,row_number() over (partition by a order by b,c) as rn
    12        from (
    13              select distinct a, b, null as c from t union
    14              select distinct a, null, c from t
    15             )
    16       )
    17  where connect_by_isleaf = 1
    18  connect by a = prior a and rn = prior rn + 1
    19* start with rn = 1
    SQL> /
    A  B          C
    A1 B1,B2      C1,C2,C3
    A2 B3         C4
    SQL>

  • ORA-01489

    How to solve this error?? Result of string concatination is too long. I'm firing a query which concats column values and displays them in a single column. Now for a table with above 300 columns in it i got the error. What should i do????

    Sorry the query is too large to post. But still i'm giving you the piece of code where the changes is required. Do you all think that converting the fields into CLOB will make it a success? Or I need to do any further changes to accept a large object.
    decode(a.CUSTOMER_SID,b.CUSTOMER_SID, null,'CUSTOMER_SID=('||a.CUSTOMER_SID||','||b.CUSTOMER_SID||')')
    ||''|| decode(a.GL_CLASS,b.GL_CLASS, null,'GL_CLASS=('||a.GL_CLASS||','||b.GL_CLASS||')')
    ||''||........ like other 300 columns.
    Do i need to do>>>>
    to_clob(decode(a.CUSTOMER_SID,b.CUSTOMER_SID, null,'CUSTOMER_SID=('||a.CUSTOMER_SID||','||b.CUSTOMER_SID||')'))
    ||''|| to_clob(decode(a.GL_CLASS,b.GL_CLASS, null,'GL_CLASS=('||a.GL_CLASS||','||b.GL_CLASS||')'))
    ||''||to_clob(......)........

  • ORA-06502 (character string buffer too small) on import application via script

    Running apex 4.2.2.00.11
    oracle 10.2.0.5
    I'm using a script to import my development application to a few production applications.
    It worked great on apex 4.1.1, but now I get an 'ORA-06502 PL/SQL numeric of value error: character string buffer too small'
    In the command window, I see that the script fails after it starts on the plugins.
    My question: is this a bug in 4.2.2?
    I could be a incompatible plugin, but how can I found out which plugin?
    My script is quite simple:
    In a command window I run
    sqlplus SCHEMA/PASSWORD@SPIEU10 @_IMPORT_F102.sql
    The script is
    declare
    l_workspace_id number;
    begin
        -- determine the workspace id for the workspace FM in the target system
        select workspace_id into l_workspace_id from apex_workspaces where workspace = 'BY_APEX_SHARED';
        -- set the context for the target workspace
        apex_application_install.set_workspace_id( l_workspace_id );
        -- override the original application id 102
        apex_application_install.set_application_id ( 102 );
        -- set a different application name and alias, it should be unique within an APEX instance
        apex_application_install.set_application_alias( 'MY_ALIAS' );
        apex_application_install.set_application_name( 'MY_APP_NAME' );
        -- Use fixed offset
        apex_application_install.set_offset( p_offset => 0);
        -- override the original parsing schema FM with a different value
        apex_application_install.set_schema( 'BY_SCHEMA' );
    end;
    -- install the original application export, now the values for the workspace
    @f102.sql
    exit;
    Error message from command window:
    ...ui types
    ...plugins
    begin
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at line 3
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64
    bit Production
    With the Partitioning, Data Mining and Real Application Testing options

    ListAGG throws an ORA-01489 for varchar2 > 4000 bytes
    OP has an ORA-06502 --> the IR is running into a 4k/32k limit.
    quick solution: wrap USER_COMMENTS ListAGG in a substr( ...., 1, 4000)
    Longer solution, use a subquery to modify the comments based on ROW_NUMBER() (ie after nth row, change it to NULL)
    with
    -- simulating data
    t as (select task_id, sysdate - lv as date_entered
      ,round(dbms_random.value(1,24)) hours
      , '-*' || lv || '.' || task_id || '*-' as user_comments
    from ( select level as task_id from dual connect by level <=10 ), (select level lv from dual connect by level < 1000)
    -- modify data
    modified_data as (
      select task_id, hours, date_entered
        ,case
          when row_number() over (partition by task_id order by date_entered desc) < 5
            then user_comments
          else null
         end USER_COMMENTS
        from t)
    select task_id, sum(hours) total_hours,
      listagg( user_comments  ) within group (order by date_entered desc)
      || case when count(*) >= 5 then '! MORE COMMENTS !' else null end
        as user_comments
    from modified_data
    group by task_id;

  • Ideas for working around ORA-06502: character string buffer too small on Interactive report

    Hello,
    This is for Apex 4.2.  We are trying to create an interactive report.  The report is for something similar to a time tracking application.  We are trying to concat a comments column while summing the hours.  For example,
    select TASK_NAME, sum(HOURS), to_char(XMLAGG(XMLELEMENT(E,E.COMMENTS || ' : ')).EXTRACT('//text()').getstringval()) USER_COMMENTS from ......
    This query works fine if we are looking only at a 1 week window.  The issue we are experiencing is that when we expand the range of the query to include data from 3 months, we hit ORA-06502 in the interactive report.  If we remove this column from the Interactive report, then the report runs fine.
    Does anyone have any ideas on how we might be able to work around this?  I am guessing we are hitting the 32k limit on the report.  Ideally we would just show the last X number of comments and then have a link to view all the comments
    Any help would be appreciated
    Thanks
    Mike

    ListAGG throws an ORA-01489 for varchar2 > 4000 bytes
    OP has an ORA-06502 --> the IR is running into a 4k/32k limit.
    quick solution: wrap USER_COMMENTS ListAGG in a substr( ...., 1, 4000)
    Longer solution, use a subquery to modify the comments based on ROW_NUMBER() (ie after nth row, change it to NULL)
    with
    -- simulating data
    t as (select task_id, sysdate - lv as date_entered
      ,round(dbms_random.value(1,24)) hours
      , '-*' || lv || '.' || task_id || '*-' as user_comments
    from ( select level as task_id from dual connect by level <=10 ), (select level lv from dual connect by level < 1000)
    -- modify data
    modified_data as (
      select task_id, hours, date_entered
        ,case
          when row_number() over (partition by task_id order by date_entered desc) < 5
            then user_comments
          else null
         end USER_COMMENTS
        from t)
    select task_id, sum(hours) total_hours,
      listagg( user_comments  ) within group (order by date_entered desc)
      || case when count(*) >= 5 then '! MORE COMMENTS !' else null end
        as user_comments
    from modified_data
    group by task_id;

  • String literal too long error while invoking a package with clob variable

    I have a package.One of the input variables of the procedure in packae is clob.
    I want to invoke this package with a huge clob as input.
    when i invoke this package like that i am getting following error
    PLS-00172 string literal too long
    can't we pass clob(huge clob) as input .is there any solution for that ?
    Thanks
    Pramod Garre

    842802 wrote:
    If insert this data into a table , from sql prompt still i get the same error.Do you mean SQL*Plus? Then there is buffer limitation and it is better to split literal into, let say 1000 character chunks:
    SQL*Plus: Release 10.2.0.4.0 - Production on Tue Mar 29 16:17:26 2011
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
      6  from dual;
    from dual
    ERROR at line 6:
    ORA-01489: result of string concatenation is too long
    SQL> select to_clob('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
      6  from dual;
    TO_CLOB('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    SQL> SY.

  • ORA-1489 error but only sometimes...when not having distinct or another function working

    So when I enter:
    SELECT opened_by from(
    SELECT  ps."NUMBER",
    ps.opened_by,
    ps.assignee_name,
    ps.closed_by,
    listagg(att.type,',') within group(order by att.type) actions,
    listagg(att.description_txt,',') within group (order by att.description_txt) descs
    from tableps ps
    LEFT JOIN activity_txt att ON ps."NUMBER" = att."NUMBER" and att.type in('Assignment','Reassignment')
    where open_time between to_date('01-OCT-2012','DD-MON-YYYY') and to_date('31-OCT-2013','DD-MON-YYYY')
    and ((ps.opened_by=ps.closed_by) and (ps.closed_by=ps.assignee_name) and (ps.assignee_name=ps.opened_by))
    group by ps."NUMBER",ps.opened_by,ps.assignee_name,ps.closed_by
    where (actions not like '%Reass%'or actions is null)
    and (descs like ('%NONE to '|| opened_by ||'%') or descs is null)
    and (descs not like '%,%' or descs is NULL);
    All is well in the world...however when I add distinct to the outer select I get the
    ORA-01489: result of string concatenation is too long
    01489. 00000 -  "result of string concatenation is too long"
    *Cause:    String concatenation result is more than the maximum size.
    *Action:   Make sure that the result is less than the maximum size.
    I don't understand the difference why one would work and one doesn't.         

    I little changed your quesry,
    Please try, if you are getting same error, then it means you have very  large desciptions in description_txt column.
    Pleasech check :
    https://forums.oracle.com/thread/2596075
    https://forums.oracle.com/message/10601105#10601105
    SELECT T."NUMBER",
        T.opened_by,
        T.assignee_name,
        T.closed_by,
        listagg(T.type,',') within GROUP(ORDER BY T.type) actions,
        listagg(T.description_txt,',') within GROUP (ORDER BY T.description_txt) descs
    FROM
      (SELECT
        ps."NUMBER",
        ps.opened_by,
        ps.assignee_name,
        ps.closed_by,att.type, att.description_txt
      FROM tableps ps LEFT JOIN activity_txt att ON ps."NUMBER" = att."NUMBER" AND att.type  IN('Assignment','Reassignment')
      WHERE open_time BETWEEN to_date('01-OCT-2012','DD-MON-YYYY') AND to_date('31-OCT-2013','DD-MON-YYYY')
        AND ((ps.opened_by   =ps.closed_by)
        AND (ps.closed_by    =ps.assignee_name)
        AND (ps.assignee_name=ps.opened_by))
         and (att.type NOT LIKE '%Reass%' OR att.type IS NULL)
         AND (att.description_txt LIKE ('%NONE to '|| opened_by ||'%') OR att.description_txt IS NULL)
         AND (att.description_txt NOT LIKE '%,%'OR att.description_txt IS NULL)) T
    Group by T."NUMBER",
        T.opened_by,
        T.assignee_name,
        T.closed_by
    And carefully read Solomon Yakobson's and Frank Kulash's replies.
    Regards
    Mahir M. Quluzade

  • How to Handle the Strings more than 4000 characters in OBIEE 11g

    Hi Folks,
    I have a derived column in RPD where there are like bunch of case statements which involve the columns from 2 or more dimensions. Now I am getting an error ORA-01489: result of string concatenation is too long at OCI call OCIStmtFetch.
    How can we handle this in OBIEE? I have tried the below option that is provided in the below link but I think this work only if it is a single column but in my case it is derived column.
    Please suggest.
    Thanks,
    Bharath

    Bharath,
    Can you try using CLOB function.Check the below URL.Not sure if it helps you.
    sql - LISTAGG function: &amp;quot;result of string concatenation is too long&amp;quot; - Stack Overflow
    Thanks,
    Sasi Nagireddy.

  • Inserting strings over 2000 in length

    Hi,
    I'm trying to populate a database table which contains a long and
    I've been running into two Oracle errors:
    ORA-01462: cannot insert string literals longer than 2000
    characters
    and
    ORA-01489: result of string concatenation is too long
    Can someone point me to documentation or a solution of how you
    can get a 29k string into the database? I have code regarding how
    to use LOBs, but I'm unfamiliar with any stored procedures which
    will allow you to append to a long column with new content. I
    need to use long for the project I am working on.
    Thanks in advance for your help!
    Jill
    null

    Hi Ralf,
    If you read the documentation on
    http://java.sun.com/products/jdbc/index.html you will
    find a statement saying that the JdbcOdbcDriver is
    only for test and experimental use.Yes, but my and other's experiences with the JDBC-ODBC bridge itself are very well.
    Since it is only a bridge over the specific vendor's ODBC driver, you are limited to the capabilities of that.
    But the bridge is not to blame for this.
    For MS products you may reach efforts by updating to an actual MDAC version.
    Nethertheless, with MS ODBC there are some problems.
    Search the driver database (a link is on the above web
    page) for another (commercial) driver. I recommend the
    type 4 driver from i-net.Ok.
    Have you tried out that error David reported with the i-net driver?
    I use JDBC-ODBC with MS SQLServer 2000, actual MDAC, and I get that error with PreparedStatement.
    But it's all ok with a normal statement.
    So if you could test them both with the i-net driver, we would see if it's again the MS ODBC driver.
    Regards,
    Ralf SchumacherI think, I'm not the first you asks this:
    you are not the quick one we saw in Suzuka on Sunday, are you?

Maybe you are looking for