Some sample code

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

Some sample code

Post by brekhof » Mon 25 Apr 2005 21:50

I would like to see some sample code how to create two or more TOraQuery's run-time. The value of the 'name' property will be entered by the user.

thanks in advance,
Martin

Alex
Posts: 655
Joined: Mon 08 Nov 2004 08:39

Post by Alex » Tue 26 Apr 2005 11:19

The run-time creation of TOraQuery components does not differ from any other components the only thing that you must to do after creation is to setup TOraSession component (server/password/username) before open datasets that linked to it.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  OraQuery_1, OraQuery_2 : TOraQuery;
begin
  OraQuery_1 := TOraQuery.Create(nil);
  OraQuery_2 := TOraQuery.Create(nil);

  //This steps are not necessary if you omit them then TOraQuery links
  //to the first available TOraSession object
  OraQuery_1.Session := OraSession1;
  OraQuery_2.Session := OraSession1;

  OraQuery_1.SQL.Clear;
  OraQuery_1.SQL.Text := 'Select * from emp';
  OraQuery_2.SQL.Clear;
  OraQuery_2.SQL.Text := 'Select * from dept1';
  OraQuery_1.Open;
  OraQuery_2.Open;
  //Do something with data

  OraQuery_1.Close;
  OraQuery_2.Close;
  OraQuery_1.Free;
  OraQuery_2.Free;
end;

Post Reply