Subject | Re: [IBO] Dead Locks? |
---|---|
Author | Markus Ostenried |
Post date | 2001-08-10T00:09:40Z |
Jason,
At 13:10 09.08.2001 -0700, you wrote:
function GetCount( Cn: TIB_Connection ): Integer;
var
Cur: TIB_Cursor;
begin
Result := 0;
Cur := TIB_Cursor.Create( nil ); // this one ?
Cur := TIB_Cursor.Create( IB_Session ); // or this one ?
try
Cur.IB_Connection := Cn;
Cur.SQL.Add( 'SELECT COUNT(FIELD1) FROM TABLE1' );
Cur.First;
Result := Cur.Fields[0].AsInteger;
finally
Cur.Free;
end;
end;
I always thought I could avoid some registering of the Cursor
with its owner if I'm going to free it "soon". If I need a Cursor more
frequently I create it once and execute i multiple times with different params.
Or should I create one Cursor and assign different SQL to it ?
TIA,
Markus
At 13:10 09.08.2001 -0700, you wrote:
>A rule of thumb for IBO is don't have nil owners for components except maybeshould I do this even in small routines like this one ?
>the TIB_Session component. If you are creating components use the
>TIB_Session instance as the owner.
function GetCount( Cn: TIB_Connection ): Integer;
var
Cur: TIB_Cursor;
begin
Result := 0;
Cur := TIB_Cursor.Create( nil ); // this one ?
Cur := TIB_Cursor.Create( IB_Session ); // or this one ?
try
Cur.IB_Connection := Cn;
Cur.SQL.Add( 'SELECT COUNT(FIELD1) FROM TABLE1' );
Cur.First;
Result := Cur.Fields[0].AsInteger;
finally
Cur.Free;
end;
end;
I always thought I could avoid some registering of the Cursor
with its owner if I'm going to free it "soon". If I need a Cursor more
frequently I create it once and execute i multiple times with different params.
Or should I create one Cursor and assign different SQL to it ?
TIA,
Markus