Add sentence if result of string concatenation is too long [message #617375] |
Fri, 27 June 2014 17:40 |
|
a415
Messages: 1 Registered: June 2014
|
Junior Member |
|
|
I am attempting to concatenate a VARCHAR2 (Contact Description) with a CLOB (Report). The result of this gives the error ORA-01489: result of string concatenation is too long. I used dbms_lob.substr to bring down the size of the clob, but I want to add the sentence "See platform for additional details" only when the string concatenation is too long, but not when it fits.
What's the best way to do this in the Description?
Here is my code:
Select '"Activity_ID","' ||
'Subject","' ||
'Description"'
from dual
union all
(select '"' || iden.identity_id || to_char(cont.contact_date,'YYYYMMDD') || to_char(cont.ref_number) || '","' || -- Activity ID
null || '","' || -- Subject
cont.contact_description || (case when cont.report is not null then 'REPORT: ' || dbms_lob.substr(cont.report,2500,1) else null end) ||'"' --Description
from contact cont,
identity iden
where cont.entity = iden.entity
and iden.change_ind is null);
[Updated on: Fri, 27 June 2014 17:48] Report message to a moderator
|
|
|
|
|
Re: Add sentence if result of string concatenation is too long [message #617671 is a reply to message #617375] |
Wed, 02 July 2014 11:17 |
|
LKBrwn_DBA
Messages: 487 Registered: July 2003 Location: WPB, FL
|
Senior Member |
|
|
Perhaps like this?:
SELECT '"Activity_ID","' || 'Subject","' || 'Description"' FROM DUAL
UNION ALL
( SELECT '"'
|| Iden.Identity_Id
|| TO_CHAR ( Cont.Contact_Date, 'YYYYMMDD' )
|| TO_CHAR ( Cont.Ref_Number )
|| '","'|| -- Activity ID
NULL
|| '","'|| -- Subject
Cont.Contact_Description
|| ( CASE
WHEN Cont.Report IS NOT NULL THEN
'REPORT: '
|| CASE
WHEN DBMS_LOB.Getlength ( Cont.Report ) > 2500 THEN
DBMS_LOB.SUBSTR ( Cont.Report, 2500, 1 )
|| CHR ( 10 )
|| 'See platform for additional details'
ELSE
Cont.Report
END
ELSE
NULL
END )
|| '"' --Description
FROM Contact Cont, Identity Iden
WHERE Cont.Entity = Iden.Entity
AND Iden.Change_Ind IS NULL );
[Updated on: Wed, 02 July 2014 11:28] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|