Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion

2975076Nov 15 2016 — edited Nov 15 2016

Hi All,

Need your Help in solving the below concern. I am getting below error while trying to insert a record into one of the table involving CLOB datatype.

Oracle DB Version: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

Error: ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 6698, maximum: 4000)

Problem Description:

I am having a master table : Atc_request_rpt having column : REPORT_FILTER_CRITERIA(CLOB) and when there is a Update/insert in that field there

needs to a record inserted into Audit table: Atc_request_rpt_audit into columns REPORT_FILTER_CRITERIA_new(clob),REPORT_FILTER_CRITERIA_old(clob).

when there is an insert/update done on that REPORT_FILTER_CRITERIA field in Atc_request_rpt (master table), the trigger through which data inserts into Audit table

Atc_request_rpt _audit(Audit table) is throwing an error :: ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 6698, maximum: 4000)

code:

CREATE OR REPLACE TRIGGER ATC_RPT_REQ_AUDIT_TRG_NEW
   AFTER INSERT OR UPDATE
   ON Atc_request_rpt REFERENCING OLD AS OLD NEW AS NEW
   FOR EACH ROW
DECLARE
   l_action_code   VARCHAR2 (2);
BEGIN
   IF INSERTING
   THEN
      l_action_code := 'I';
   ELSIF UPDATING
   THEN
      l_action_code := 'U';
   END IF;

DBMS_OUTPUT.PUT_LINE('1');
   IF (l_action_code = 'I'
       OR (l_action_code = 'U'
           AND ( NVL ( :OLD.REPORT_FILTER_CRITERIA, 'X')  <>
                     NVL ( :NEW.REPORT_FILTER_CRITERIA, 'X')
                )))

   THEN
   DBMS_OUTPUT.PUT_LINE('2');
      INSERT
        INTO Atc_request_rpt_audit (REQUEST_ID,
                                                AUDIT_TYPE,
                                                REPORT_FILTER_CRITERIA_NEW,
                                                REPORT_FILTER_CRITERIA_OLD
                                                )
      VALUES (
                DECODE (:OLD.REQUEST_ID,
                        NULL, :NEW.REQUEST_ID,
                        :OLD.REQUEST_ID),
                l_action_code,
                DECODE (
                   l_action_code,
                   'I',  :NEW.REPORT_FILTER_CRITERIA,
                   'U',  :NEW.REPORT_FILTER_CRITERIA),
                DECODE (
                   l_action_code,
                   'I', NULL,
                   'U', :OLD.REPORT_FILTER_CRITERIA)
                );

   END IF;
      EXCEPTION
  WHEN OTHERS THEN
                 DBMS_OUTPUT.PUT_LINE(sqlerrm);

END;
/

So I have added dbms_lob.substr( :OLD.REPORT_FILTER_CRITERIA, 4000, 1 ), now record is getting inserted but the result of the column is truncated to 4000(characters) but

the requirement is that the REPORT_FILTER_CRITERIA value in Master table: ATC_RPT_REQ should be inserted into audit table : ATC_RPT_REQ_AUDIT without truncation of 4000 characters.

is there any way to do it ?

Thanks

This post has been answered by Paulzip on Nov 15 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 13 2016
Added on Nov 15 2016
8 comments
3,617 views