I'm not sure if you're just over-thinking this. A varchar2
is always going to be smaller than a long
or clob
could be, so you can just assign your value. It's going the other way that causes problems. You can just do this in SQL:
insert into t42 (long_val, clob_val)
values ('any string up to 4000 chars', 'any other string up to 4000 chars');
Or from PL/SQL:
declare
char_val varchar2(4000);
begin
char_val := 'another string';
insert into t42 (long_val, clob_val)
values (char_val, char_val);
end;
/
SQl Fiddle demo. I believe that all worked the same in 8i as it does now in 11g.
The PL/SQL varchar2
can be up to 32k and still be inserted like this.