Link to home
Start Free TrialLog in
Avatar of ramavenkatesa
ramavenkatesa

asked on

oracle concatenation error

set echo off
set feedback off
set linesize 30000
set trimspool on
set termout off
set pagesize 1000
set verify off
SET HEADING off
spool /u15/moneta/Moneta_Feed.txt
Select distinct(a.complaint_id)|| '|' ||d.DATE_CREATED|| '|' ||d.DATE_CLOSED|| '|' ||d.served_date|| '|' ||d.cust_sat_date|| '|' ||b.complaint_tel_num|| '|' ||
b.BILLING_TEL_NUM || '|' || a.COMPLAINT_NATURE|| '|' || a.ROOTCAUSE|| '|' || a.ACTION_RESOLUTION|| '|' || m.STATE|| '|' || b.service_city|| '|' || g.source_desc|| '|' ||
b.cust_type|| '|' || concat(uinfo.user_last_name,uinfo.user_first_name)|| '|' || concat(b.cust_last_name,b.cust_first_name)|| '|' || concat(uinfo.user_last_name,uinfo.user_first_name)|| '|' ||
k.center_name|| '|' || h.topic_code|| '|' || h.topic_desc|| '|' || c.dept_name|| '|' || l.keyword_def|| '|' || n.carrier_desc|| '|' || a.SUBCIC|| '|' || p.product_name|| '|' || q.action_name|| '|' ||
q.ACTION_DESC|| '|' || s.satisfaction_name|| '|' || s.satisfaction_desc|| '|' || i.business_unit|| '|' || concat(u.DIRECTOR_LAST_NAME ,u.DIRECTOR_FIRST_NAME)|| '|' ||
concat(v.EXECUTIVE_LAST_NAME , v.EXECUTIVE_FIRST_NAME)|| '|' || a.STATE_COMM_CODE|| '|' || a.REFERENCE_NUM|| '|' || a.LD_ROOT_CAUSE_ID|| '|' || x.DATE_CLOSED|| '|' ||  x.DECISION_ISSUE|| '|' || x.ORAL_WRITTEN|| '|' ||
x.VIOLATION|| '|' || x.CHAPTER|| '|' || z.SOURCE_TYPE_DESC FROM
        vectrdba.COMPLAINT_INFO a,vectrdba.ACCOUNT_INFO b,vectrdba.DEPARTMENT_INFO c, vectrdba.TIME_INFO d,
        vectrdba.STATUS_INFO e, vectrdba.COMPLAINT_TYPE f,vectrdba.SOURCE_INFO g, vectrdba.TOPIC_INFO h,
        vectrdba.BUSINESS_UNIT_INFO i, vectrdba.BUSINESS_UNIT_TOPIC j,vectrdba.CENTER_INFO k, vectrdba.KEYWORD_INFO l,
        vectrdba.STATE_INFO m,vectrdba.CARRIER_INFO n, vectrdba.PRODUCT_INFO p,vectrdba.ACTION_INFO q, vectrdba.SATISFACTION_INFO s,
         vectrdba.DIRECTOR_INFO u, vectrdba.EXECUTIVE_INFO v, vectrdba.VECTR_OPEN_CLOSING_INFO x, vectrdba.SOURCE_TYPE_INFO z,
         vectrdba.USER_INFO uinfo , vectrdba.LOCATION_INFO loc, vectrdba.REGION_INFO reg where
    d.DATE_CLOSED >= (sysdate -1)  and d.DATE_CLOSED < sysdate and
    a.account_id = b.account_id(+) and
    b.complaint_tel_num IS NOT NULL and
    a.time_id = d.time_id(+) and
    a.DEPT1_ID = c.DEPT_ID(+) and
    a.status_id = e.status_id(+) and
    e.status_id = '2' and
    a.COMPLAINT_TYPE_ID = f.COMPLAINT_TYPE_ID(+) and
    a.source_id = g.source_id(+)and
    a.BUSINESS_UNIT_TOPIC1_ID = j.BUSINESS_UNIT_TOPIC_ID(+) and
    j.BUSINESS_UNIT_ID = i.BUSINESS_UNIT_ID(+) and
    j.TOPIC_ID = h.TOPIC_ID(+) and
    a.CENTER_ID = k.CENTER_ID(+) and
    a.KEYWORD1_ID= l.KEYWORD_ID(+) and
    b.STATE_ID = m.STATE_ID(+) and
    a.CARRIER1_ID = n.CARRIER_ID(+) and
    a.PRODUCT1_ID = p.PRODUCT_ID(+) and
    a.ACTION_ID1 = q.ACTION_ID(+) and
    a.SATISFACTION_ID1 = s.SATISFACTION_ID(+) and
    a.DIRECTOR1_ID = u.DIRECTOR_ID(+) and
    a.EXECUTIVE_ID = v.EXECUTIVE_ID(+) and
    a.SOURCE_TYPE_ID = z.SOURCE_TYPE_ID(+) and
    a.complaint_id = x.complaint_id(+) and
    a.AUTHOR_USER_ID = uinfo.USER_ID(+) and
    a.SEC_AUTHOR_USER_ID = uinfo.USER_ID(+) and
    b.STATE_ID IS NOT NULL and
    b.STATE_ID = loc.STATE_ID(+) and  
    loc.REGION_ID = reg.REGION_ID(+);
 spool off


-- while i am executing the query -- i am getting an error of ERROR: ORA-01489: result of string concatenation is too long
can anybody please tell me the options?
Avatar of Sean Stuber
Sean Stuber

if you concatenate more than 4000 characters you will get that result .

Since you're using sqlplus and you are simply creating a pipe-delimited list,  why not set your column separator to | and just return the columns without concatenating?
Avatar of ramavenkatesa

ASKER

how can i do that ?
can other persons use this file to upload into their database?
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
actually it's not going to be "exactly" the same as concatenating.

the columns will be fix width as well as delimited
can i use concatenation and solve the problem? --- basically by using pl/sql block ?
in pl/sql  varchar2 can go up to 32767 characters so you could concatenate and then spool it out with dbms_output if 10g or higher.

you could also concatenate into a clob  
can u please give me an example?