Subject Re: [IBO] fastest IB_Cursor... how???
Author Helen Borrie
At 04:10 AM 7/09/2006, you wrote:
>Thanx Dany...
>
>I was digging in the source code of IBO, and found that Jason use
>TIB_SchemaCursor in those queries...
>
>should i use TIB_SchemaCursor for my query instead of TIB_Cursor???
>what are the differences???
>
>here i'll show one of my procedures:
>
>function TDM_Conexion.ObtenCampo(S: string): TIB_Column;
>begin
> with IB_Cursor1 do
> begin
> SQL.Text := S;
> ReadOnly := True;
> BeginBusy(true);
> try
> First;
> Result := Fields[0];
> finally
> EndBusy;
> end;
> end;
>end;
>
>this function returns the pointer to a TIB_Column that should be the
>first field in the query passed as parameter... useful to make
>Count's and stuff like that where just one value is requested to the
>DB.
>
>are there anything that could be perfectible??? i'm getting good
>results of speed as is... but just wondering about if i'm missing
>something.

No, this is more or less the right way to retrieve a single value or
a singleton row. The syntax in the above code isn't quite right,
though, you should retrieve your result AsString in your example.

Your example seems to suggest that you are re-using the same
IB_Cursor object for different statements. If so, your function
should clean up after it has finished reading the value.

However, if the the IB_Cursor is really intended for use to pass the
*same* statement each time, using just different values for an
otherwise static WHERE clause, then you can improve performance
considerably. Make the SQL persistent, use parameters, and assign
the parameter value[s] instead of replacing the statement each time
you call the function.

Helen