How to set Unidirectional to True in TOraQuery(or TOraDataset) than got REF from server?

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kms
Posts: 4
Joined: Tue 16 Nov 2004 11:39

How to set Unidirectional to True in TOraQuery(or TOraDataset) than got REF from server?

Post by kms » Tue 06 Feb 2007 14:00

Hello!

I want to get REF Cursor from stored procedure, assign it to some TOraDataSet exemplar and save all its records in the cycle to text file.

But if I do it with

Code: Select all

 ds : TOraDataSet;
 sres:String;
begin

 dmImport.StatListLibClient(ds);



1. Is it possible to assign just received cursor to some TOraDataSet variable and immediately set Unidirectional to True to prevent buffering record in cash ?

2. If not, is there another method to save cursor records to client file without buffering ALL them on the client memory ?

3. Additional question. What should I do if I have a DataSet that is NonUnidirectional and linked to TCRDBGrid with TOraDataSource, but I still want to save it to file with switching buffering off?

Thank you!

Code: Select all

// ORA_TYPE_CURSOR is synonym of TOraDataSet
procedure TdmImport.StatListLibClient(o_refcur: ORA_TYPE_CURSOR); 
var
   tmp : TOraStoredProc;
begin
  tmp := TOraStoredProc.Create(nil);
  try
    tmp.Session := OraSession1;
    tmp.StoredProcName := 'cscman.pck_LIB_MANAGEMENT.stat_list_lib_client';
    tmp.PrepareSQL;

    tmp.ParamByName('i_username').AsString := OraSession1.Username;
    tmp.ParamByName('o_refcur').ParamType := ptOutput;
    tmp.Execute;

    tmp.Open;
    O_REFCUR := tmp;
    except
    on e:Exception do begin
     winMainForm.addLog('TdmImport.StatListLibClient' +e.message);
    end;
    end;

end; 

Maxim

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

Post by Plash » Wed 07 Feb 2007 15:12

TOraStoredProc component opens a cursor that is returned from a stored procedure automatically when you call the Open or Execute methods of TOraStoredProc. You can set the Unidirectional property of TOraStoredProc to True to prevent the component from caching all records in memory.

If you want to assign a cursor to another dataset, use the TOraSQL component instead of TOraStoredProc. TOraSQL does not open a cursor returned from a stored procedure. So a dataset that you assign a cursor to, will be able to open this cursor. Set the Unidirectional property of a dataset that opens a cursor to True. You can use the following code:

Code: Select all

  OraQuery.Cursor:= OraSQL.ParamByName('o_refcur').AsCursor;
  OraQuery.Open;

Post Reply