Passing Memo Text to Clob Field by TOraStoredProc

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
brunomaximomogi
Posts: 2
Joined: Thu 18 Oct 2007 05:43

Passing Memo Text to Clob Field by TOraStoredProc

Post by brunomaximomogi » Thu 18 Oct 2007 06:07

Hi I would like to know which one is the best way when need to record the contents from some memo component to a clob field on table, using tOraStoredProc. I´m declaring the clob field as ftString like this:

vStored.Params.CreateParam(ftString,'P_SINOPSE',ptInput);

and passing value to it like this:

vStored.Params.ParamByName('P_SINOPSE').AsString:=MemSinopse.text;

is this the best way to work? My procedure header is like this:

...P_SINOPSE IN CLOB...

Please, let me know if I´m doing something wrong. ftString is the best declaration type to receive some Tmemo data?

thanks

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

Post by Plash » Thu 18 Oct 2007 12:36

You should use a parameter of ftOraClob type. Use the following code to pass a value to the parameter:

Code: Select all

vStored.ParamByName('P_SINOPSE').AsOraClob.AsString := MemSinopse.Text;
You also need to set the TemporaryLobUpdate option of TOraStoredProc to True.

brunomaximomogi
Posts: 2
Joined: Thu 18 Oct 2007 05:43

Doesn´t Work

Post by brunomaximomogi » Thu 18 Oct 2007 13:31

Hi Plash, Thanks for the answer, but when I did that I got an "Access Violation Address". When I remove The AsOraClob and the changes the ftOraClob to ftString. Everything works fine! I´m using Oracle 10G Xe 10.2.0.1 and Delphi 7 with ODAC 5.10. Thanks

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

Post by Plash » Fri 19 Oct 2007 11:56

The TemporaryLobUpdate option was added in ODAC 6. For ODAC 5, try to use the following code:

Code: Select all

var
  Lob: TOraLob;
begin
  Lob := vStored.ParamByName('P_SINOPSE').AsOraClob;
  Lob.AsString := MemSinopse.Text;
  Lob.OCISvcCtx := OraSession1.OCISvcCtx;
  Lob.CreateTemporary(ltClob);
  Lob.WriteLob;

  vStored.Execute;
end;
TOraLob is declared in the OraClasses unit.

Post Reply