Page 1 of 1

Passing Memo Text to Clob Field by TOraStoredProc

Posted: Thu 18 Oct 2007 06:07
by brunomaximomogi
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

Posted: Thu 18 Oct 2007 12:36
by Plash
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.

Doesn´t Work

Posted: Thu 18 Oct 2007 13:31
by brunomaximomogi
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

Posted: Fri 19 Oct 2007 11:56
by Plash
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.