Question on partial CLOB read from query field.

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Question on partial CLOB read from query field.

Post by MarkF » Fri 06 Apr 2007 19:25

Hi Folks!

Is it possible to read the initial say 100 bytes of a CLOB or BLOB? I'm trying to do something along the lines of:

Query.Options.DeferredLobRead := False;
Query.Options.CacheLobs := True;

Query.SQL.Text := 'select myclob from mytable where id = 1';
Query.Execute;
if not Query.EOF then
begin
// read 100 bytes into field's value such that it will
// not read the full information from the server,
// I'd like to cache it in the dataset so it isn't re-read later.
end;

I've tried a few things but so far haven't got it to work. Any suggestions greatly appreciated!

-Mark

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 10 Apr 2007 07:37

You should set the DeferredLobRead option to True and CachLobs to False. Then you can use the code like this:

Code: Select all

var
  Lob: TOraLob;
  s: string;
begin
  OraQuery.Open;
  Lob := OraQuery.GetLob('MYCLOB');
  SetLength(s, 100);
  Lob.Read(0, 100, @s[1]);
end;
ODAC does not support caching of partial LOB values. If the CachLobs option is set to True, the whole LOB value is readed and cached.
If the CachLobs option is set to False, ODAC reads data from the database every time when you call the TOraLob.Read method.

Post Reply