3. Dealing with CLOBs
Strings form CLOBs can be read without any additional work. Writing to CLOB is more complicated. You need two things: PL/SQL function (in database) and VBScript function:
CREATE OR REPLACE FUNCTION CreateClob (
t01 varchar2 default null,
t02 varchar2 default null,
t03 varchar2 default null,
t04 varchar2 default null,
t05 varchar2 default null,
t06 varchar2 default null,
t07 varchar2 default null,
t08 varchar2 default null,
t09 varchar2 default null,
t10 varchar2 default null,
t11 varchar2 default null,
t12 varchar2 default null,
t13 varchar2 default null,
t14 varchar2 default null,
t15 varchar2 default null,
t16 varchar2 default null,
t17 varchar2 default null,
t18 varchar2 default null,
t19 varchar2 default null,
t20 varchar2 default null,
t21 varchar2 default null,
t22 varchar2 default null,
t23 varchar2 default null,
t24 varchar2 default null,
t25 varchar2 default null
) return clob
IS
wyn clob := null;
begin
IF wyn IS NULL THEN wyn := t01; ELSIF t01 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t01); END IF;
IF wyn IS NULL THEN wyn := t02; ELSIF t02 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t02); END IF;
IF wyn IS NULL THEN wyn := t03; ELSIF t03 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t03); END IF;
IF wyn IS NULL THEN wyn := t04; ELSIF t04 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t04); END IF;
IF wyn IS NULL THEN wyn := t05; ELSIF t05 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t05); END IF;
IF wyn IS NULL THEN wyn := t06; ELSIF t06 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t06); END IF;
IF wyn IS NULL THEN wyn := t07; ELSIF t07 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t07); END IF;
IF wyn IS NULL THEN wyn := t08; ELSIF t08 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t08); END IF;
IF wyn IS NULL THEN wyn := t09; ELSIF t09 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t09); END IF;
IF wyn IS NULL THEN wyn := t10; ELSIF t10 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t10); END IF;
IF wyn IS NULL THEN wyn := t11; ELSIF t11 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t11); END IF;
IF wyn IS NULL THEN wyn := t12; ELSIF t12 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t12); END IF;
IF wyn IS NULL THEN wyn := t13; ELSIF t13 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t13); END IF;
IF wyn IS NULL THEN wyn := t14; ELSIF t14 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t14); END IF;
IF wyn IS NULL THEN wyn := t15; ELSIF t15 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t15); END IF;
IF wyn IS NULL THEN wyn := t16; ELSIF t16 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t16); END IF;
IF wyn IS NULL THEN wyn := t17; ELSIF t17 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t17); END IF;
IF wyn IS NULL THEN wyn := t18; ELSIF t18 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t18); END IF;
IF wyn IS NULL THEN wyn := t19; ELSIF t19 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t19); END IF;
IF wyn IS NULL THEN wyn := t20; ELSIF t20 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t20); END IF;
IF wyn IS NULL THEN wyn := t21; ELSIF t21 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t21); END IF;
IF wyn IS NULL THEN wyn := t22; ELSIF t22 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t22); END IF;
IF wyn IS NULL THEN wyn := t23; ELSIF t23 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t23); END IF;
IF wyn IS NULL THEN wyn := t24; ELSIF t24 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t24); END IF;
IF wyn IS NULL THEN wyn := t25; ELSIF t25 IS NOT NULL THEN DBMS_LOB.APPEND(wyn, t25); END IF;
return wyn;
end;
Function ToClob(str)
nMax = 4000
nParam = 25
str = CStr(str)
if Len(str) <= nMax Then
ToClob = "'" & str & "'"
Else
wyn = "CreateClob("
Set rx = New RegExp
rx.IgnoreCase = True
rx.Pattern = "^([^']|'')*$"
For n = 1 to nParam
If n > 1 Then
wyn = wyn & ","
End If
If Len(str) <= nMax Then
wyn = wyn & "'" & str & "'"
Exit For
Else
ss = Left(str, nMax)
If Right(ss, 1) = "'" Then 'poprawka par apostrofow
If rx.Test(ss) Then
str = Mid(str, nMax+1)
Else
ss = Left (ss, nMax-1)
str = Mid(str, nMax)
End If
ElseIf Right(ss, 1) = "\" And Mid(str, nMax+1, 1) = "&" Then 'poprawka ciagu \&
ss = Left (ss, nMax-1)
str = Mid(str, nMax)
Else
str = Mid(str, nMax+1)
End If
wyn = wyn & "'" & ss & "'"
End If
Next
ToClob = wyn & ")"
Set rx = Nothing
End If
End Function
<