Board index » delphi » how can I get the the percentage of the query process

how can I get the the percentage of the query process

Hi !
I have SQL statments that it takes a long time (maybe few minutes) to get
the results.
I want to make a progress bar in order to represent the time it going to
last.
My question is how can I get the percentage of the query process (during the
process)?

Thanks in advance!!

 

Re:how can I get the the percentage of the query process


You must register a BDE callBack of type cbGENPROGRESS.

eyal wilde escribi en mensaje <6lledc$8...@forums.borland.com>...

Quote
>Hi !
>I have SQL statments that it takes a long time (maybe few minutes) to get
>the results.
>I want to make a progress bar in order to represent the time it going to
>last.
>My question is how can I get the percentage of the query process (during
the
>process)?

>Thanks in advance!!

Re:how can I get the the percentage of the query process


I don't have much experiance with this stuff.
can you give me detailed example ?

thanks in advanced !!

Quote
David Mart wrote in message <6lmhhb$9...@forums.borland.com>...
>You must register a BDE callBack of type cbGENPROGRESS.

>eyal wilde escribi en mensaje <6lledc$8...@forums.borland.com>...
>>Hi !
>>I have SQL statments that it takes a long time (maybe few minutes) to get
>>the results.
>>I want to make a progress bar in order to represent the time it going to
>>last.
>>My question is how can I get the percentage of the query process (during
>the
>>process)?

>>Thanks in advance!!

Re:how can I get the the percentage of the query process


TI3103 describes a D2/3 BDE callback arrangement. I could not make much
sense of it I seem to recall, but worked out something for D1. If that
is of use to you, come back.

(PS. I'm not certain this would work on a query any way as how can the
BDE know the percentage done? My requirement was for a batchmove.)

Bob
--

Using Virtual Access
http://www.vamail.com

Re:how can I get the the percentage of the query process


I akesd the following question a few days ago :

I have SQL statments that it takes a long time (maybe few minutes) to get
the results.
I want to make a progress bar in order to represent the time it going to
last.
My question is how can I get the percentage of the query process (during the
process)?

I have got an answer from David M:

You must register a BDE callBack of type cbGENPROGRESS.

but I do not have any experience with this particular stuff.
I have found some information in the BDE API Help documentation at
'DbiRegisterCallBack' page.
I afraid to admit that I have got lost.
My basic questions are :
1) how to call BDE API function ?
2) how to register a BDE callBack ? (maybe by using
TBDEDataSet.ConstraintCallBack mothod??)
Detailed example would be great!
thanks in advance!!

Re:how can I get the the percentage of the query process


Here is the D1 batchmove demo I put together for myself. If you are
using D2/3 then look at TI3103 to see how to adapt.

Bob

unit Unit1;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, DB, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls,
Gauges,
  DBTables ;

type
  TForm1 = class(TForm)
    Table1: TTable;
    Table2: TTable;
    BatchMove1: TBatchMove;
    Button1: TButton;
    DBGrid1: TDBGrid;
    DBNavigator1: TDBNavigator;
    DataSource1: TDataSource;
    Label1: TLabel;
    Panel1: TPanel;
    Gauge1: TGauge;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses  DbiTypes, DbiProcs ;

{$R *.DFM}

var
  InfoBuff: cbProgressDesc;

function ShowProgress( x: cbType; y: Longint;
                      var z: Pointer): cbrType ; export ;
var s: string;
begin
  with InfoBuff, Form1.Gauge1, Form1.Label1 do begin
    if iPercentDone < 0 then begin
        s := StrPas(@szMsg);
        Caption := s;
        Update;
        Delete(s, 1, Pos(': ', s) + 1);
        Progress := Round((StrToInt(s) / Form1.Table1.RecordCount) *
100);
    end else begin
      Caption := '% Complete = '+ IntToStr(iPercentDone);
      Update;
      Progress := iPercentDone;
    end;
  end;
  Result := cbrCONTINUE;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Table1.Open;
  Table2.Close;
  Check(DbiRegisterCallback( nil,
                             cbGENPROGRESS,
                             0,
                             sizeof(InfoBuff),
                             @InfoBuff,
                             ShowProgress));

  BatchMove1.Execute;
  Check(DbiRegisterCallback( nil,
                             cbGENPROGRESS,
                             0,
                             0,
                             nil,
                             nil));
  Gauge1.Progress := 0;
  Table2.Open;
end;

end.

============================== Form File Follows ==================
object Form1: TForm1
  Left = 184
  Top = 97
  Width = 427
  Height = 273
  Caption = 'Form1'
  Font.Color = clWindowText
  Font.Height = -13
  Font.Name = 'System'
  Font.Style = []
  PixelsPerInch = 96
  TextHeight = 16
  object Label1: TLabel
    Left = 215
    Top = 210
    Width = 4
    Height = 16
  end
  object Button1: TButton
    Left = 7
    Top = 206
    Width = 48
    Height = 26
    Caption = 'Run'
    TabOrder = 0
    OnClick = Button1Click
  end
  object DBGrid1: TDBGrid
    Left = 6
    Top = 38
    Width = 407
    Height = 160
    DataSource = DataSource1
    TabOrder = 1
    TitleFont.Color = clWindowText
    TitleFont.Height = -13
    TitleFont.Name = 'System'
    TitleFont.Style = []
  end
  object DBNavigator1: TDBNavigator
    Left = 9
    Top = 6
    Width = 401
    Height = 25
    DataSource = DataSource1
    TabOrder = 2
  end
  object Panel1: TPanel
    Left = 59
    Top = 204
    Width = 150
    Height = 29
    BevelInner = bvLowered
    TabOrder = 3
    object Gauge1: TGauge
      Left = 2
      Top = 2
      Width = 146
      Height = 25
      Align = alClient
      ForeColor = clNavy
      BackColor = clBtnFace
      Progress = 0
    end
  end
  object Table1: TTable
    DatabaseName = 'c:\delphi\practice\data'
    TableName = 'CUSTOMER.DBF'
    Left = 31
    Top = 102
  end
  object Table2: TTable
    DatabaseName = 'c:\delphi\practice\data'
    TableName = 'temp'
    Left = 85
    Top = 98
  end
  object BatchMove1: TBatchMove
    Destination = Table2
    Mode = batCopy
    RecordCount = 4500
    Source = Table1
    Left = 167
    Top = 101
  end
  object DataSource1: TDataSource
    DataSet = Table2
    Left = 120
    Top = 100
  end
end

Other Threads