'Two CLOB values need to append in DB2

Set ls_total=ls_concat1 || ls_cocat2;

Getting "is too long" error came

Note:ls_concat1,ls_cocat2,ls_total are CLOB datatypes



Solution 1:[1]

The CLOB data type has length in Db2.
It's obvious, that a variable must have an appropriate length to hold the result value.
There is no error in the example below, but you get it, if you define ls_total as CLOB (9) - with insufficient length.

BEGIN
    DECLARE ls_total CLOB (10);
    --DECLARE ls_total CLOB (9);

    DECLARE ls_concat1, ls_concat2 CLOB (5);
    
    SET ls_concat1 = 'ABCDE', ls_concat2 = 'ABCDE';
    SET ls_total = ls_concat1 || ls_concat2;
END@

If it doesn't answer your question, then post some reproducible example which returns the error you mentioned.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mark Barinstein