Insert and Update CLOB fields over 4000 characters

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for Oracle in Delphi and C++Builder
Post Reply
dmuntane
Posts: 1
Joined: Tue 13 Jul 2010 09:39

Insert and Update CLOB fields over 4000 characters

Post by dmuntane » Tue 13 Jul 2010 10:12

When inserting/updating CLOB fields with a size over 4000, field value is set to null.

Environment:
Delphi 7
dbexpoda.dll: Version 4.50.0.21
Oracle: Version 9i and 10 (XE)

Test cases:

CREATE TABLE TEST (CLOBFIELD CLOB)
INSERT INTO TEST (CLOBFIELD) VALUES ()
Result: No data is stored

UPDATE TEST SET CLOBFIELD=
Result: Data deleted (CLOBFIELD=null)


I am also using .NET driver and it works!


Regards,
dvd

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Thu 15 Jul 2010 09:39

Hello

You can insert CLOB data by the following code:

Code: Select all

var
  i: integer;
  str: string;
begin
  for i := 0 to 19999 do
    str := str + Char(RandomRange(byte('a'), byte('z')));

  SQLQuery1.SQL.Text := 'insert into btest6 (id, name, myclob) values (10, ''test clob'', EMPTY_CLOB()) ' + #13 +
                        'RETURNING ' + #13 +
                        '  myclob ' + #13 +
                        'INTO ' + #13 +
                        ' :myclob';

  SQLQuery1.ParamByName('myclob').ParamType := ptInput;
  SQLQuery1.ParamByName('myclob').DataType := ftOraClob;
  SQLQuery1.ParamByName('myclob').Value := str;

  SQLQuery1.ExecSQL;
end;
The DDL script for creating this table:

Code: Select all

CREATE TABLE TEST_CLOB (
  ID NUMBER,
  NAME VARCHAR2(50),
  MYCLOB CLOB,
  CONSTRAINT PK_TEST_CLOB PRIMARY KEY (ID)
)

Post Reply