Subject | Re: [IBO] Dead Locks? |
---|---|
Author | Jason Wharton |
Post date | 2001-08-10T03:11:59Z |
Preferably yes you should.
Here is what you would do.
<raise some sort of exception or exit.>
Cur := TIB_Cursor.Create( Cn.IB_Session ); // or this one ?
// Hook into the session of the connection. That way they will both be in
the same session context.
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com
Here is what you would do.
> function GetCount( Cn: TIB_Connection ): Integer;if not Assigned( Cn ) then
> var
> Cur: TIB_Cursor;
> begin
> Result := 0;
<raise some sort of exception or exit.>
> Cur := TIB_Cursor.Create( nil ); // this one ?// Neither.
> Cur := TIB_Cursor.Create( IB_Session ); // or this one ?
Cur := TIB_Cursor.Create( Cn.IB_Session ); // or this one ?
// Hook into the session of the connection. That way they will both be in
the same session context.
> tryHope this helps,
> Cur.IB_Connection := Cn;
> Cur.SQL.Add( 'SELECT COUNT(FIELD1) FROM TABLE1' );
> Cur.First;
> Result := Cur.Fields[0].AsInteger;
> finally
> Cur.Free;
> end;
> end;
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com
----- Original Message -----
From: "Markus Ostenried" <chef_007@...>
To: <IBObjects@yahoogroups.com>
Sent: Thursday, August 09, 2001 5:09 PM
Subject: Re: [IBO] Dead Locks?
> Jason,
>
> At 13:10 09.08.2001 -0700, you wrote:
> >A rule of thumb for IBO is don't have nil owners for components except
maybe
> >the TIB_Session component. If you are creating components use the
> >TIB_Session instance as the owner.
>
> should I do this even in small routines like this one ?
>
> 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
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>