Subject Re: [IBO] Need help with a simple OnCallBack for a progress meter
Author Helen Borrie
At 08:43 AM 30/06/2005 -0700, you wrote:
>Hello:
>
>I'm just trying to get a progress bar for a lengthy query which uses a
>UDF. I've searched the archives for the correct use of OnCallBack, but
>for some reason, I just can't get it to work.
>
>Could someone please help me out? It seems that OnCallBack is never
>fired, although I understood from the archives that using a SELECT
>PROCEDURE with SUSPEND would do that.
>
>I admit that below is the first stored procedure I ever wrote, too.
>
>I'm using IBO 4.2Ie, XP, D7 and FireBired Embedded, local/desktop
>application. The table, MasterLibrary, has 41,000 records.
>
>I've confirmed that the procedure actually works in IB_SQL.
>
>Thank you,
>
>Chuck Belanger
>
>
>//ib_cursor settings:
>CallBackInc := 1
>CallBackInitInt := 1
>CallBackRefresh := 1
>
>//button's OnCLick event for testing
>with ib_cursor do
>begin
>
> SQL.Clear;
> Sql.Add('SELECT * FROM myProc(Param) ');
> Execute;

This is wrong. You don't call Execute to open a dataset. For an
ib_cursor, you should call First and, subsequently, Next.

> end;
>
>
>//OnCallBack event for IB_cursor:
>fcProgressBar1.Progress := Trunc((CursorRowNum/TotalRows)*100);

How will you know what TotalRows is for an ib_cursor? (Just curious...)


>//stored procedure from IB_Expert for myProc
>begin
> /* Procedure Text */
> for select m.ml_id, myUDF(m.ml_item,:K) ,
> myUDF(m.ml_upper_item,:K)
> from MasterLibrary m
> Order by 3
> INTO
> :MLID,
> :MLITEM,
> :MLUPITEM
> do begin
> suspend;
> end
>end

Take a look at IBF_Datapump.pas for an OnCallBack handler. Examine the
invoked procedure, CursorCallback, to see a progress-style callback at work.

Helen