Subject | Using a single TIB_Cursor for all |
---|---|
Author | Dennis McFall |
Post date | 2004-11-15T16:03:24Z |
I have a question about using a single (global, so to speak) TIB_Cursor
component (perhaps on a DataModule) for all SELECT statements for an
entire application.
Suppose 10 clients running a Delphi application on Win_____, with
Firebird server on Win or Linux. The Delphi application has, say, 500
places where it needs data from the database. 50 of those are to create
static selection lists in TListBoxes, the other 450 are the usual
looking up details of names, invoices, payments, inventory items,
receipt numbers, etc. etc.
I can think of three options:
1. Using the same curFactotum for every select:
with DataModule1.curFactotum do try
SQL.Clear;
SQL.Add('SELECT SUM(AMOUNT )FROM PAYMENTS WHERE PAYER_ID=1234' );
First;
if not eof then while not eof do begin
DoSomethingWith_Fields[0].AsString:
Next;
finally
Close;
Unprepare; // is this necessary re: server resources?
end;
-------------------------------
2. Create 500 'static' TIB_Cursor components with 'static'
parameterised SQL:
with DataModule1.curSumPaymentsForPayer do try
if not prepared then prepare;
Params[0].AsInteger:=iParam;
First;
if not eof then while not eof do begin
DoSomethingWith_Fields[0].AsFloat:
Next;
finally
Close;
Unprepare; // unless we think we'll use it again
end;
---------------------------------
3. Set up, and select from, a Stored Procedure
-------------------------------------------
Also: Is the result of calling "unprepare" (releasing resources on the
server?? Nothing else?) carried out automatically by calling
"curFactotum.SQL.Clear" ?
Thanks for the insight.
Dennis McFall
component (perhaps on a DataModule) for all SELECT statements for an
entire application.
Suppose 10 clients running a Delphi application on Win_____, with
Firebird server on Win or Linux. The Delphi application has, say, 500
places where it needs data from the database. 50 of those are to create
static selection lists in TListBoxes, the other 450 are the usual
looking up details of names, invoices, payments, inventory items,
receipt numbers, etc. etc.
I can think of three options:
1. Using the same curFactotum for every select:
with DataModule1.curFactotum do try
SQL.Clear;
SQL.Add('SELECT SUM(AMOUNT )FROM PAYMENTS WHERE PAYER_ID=1234' );
First;
if not eof then while not eof do begin
DoSomethingWith_Fields[0].AsString:
Next;
finally
Close;
Unprepare; // is this necessary re: server resources?
end;
-------------------------------
2. Create 500 'static' TIB_Cursor components with 'static'
parameterised SQL:
with DataModule1.curSumPaymentsForPayer do try
if not prepared then prepare;
Params[0].AsInteger:=iParam;
First;
if not eof then while not eof do begin
DoSomethingWith_Fields[0].AsFloat:
Next;
finally
Close;
Unprepare; // unless we think we'll use it again
end;
---------------------------------
3. Set up, and select from, a Stored Procedure
-------------------------------------------
Also: Is the result of calling "unprepare" (releasing resources on the
server?? Nothing else?) carried out automatically by calling
"curFactotum.SQL.Clear" ?
Thanks for the insight.
Dennis McFall