Small change to TOracleDataSet.PSSetParams

mwlang

Member²
Using D5 and MIDAS, I encountered a problem with D5 that I didn't have with D4.

In my AppServer, I have some server side session info that I plug into a variable for a TOracleDataSet's SQL during a provider's OnDataRequest Event that was being cleared out by a call to DeleteVariables in the TOracleDataSet.PSSetParams call. To get around this problem, instead of deleting all the variables at the beginning of the procedure, I check to see if it exists before calling DeclareVariable. The following code is the 2 line change marked by "{ MWL }"

procedure TOracleDataSet.PSSetParams(AParams: TParams);
var p, DataType: Integer;
begin
// DeleteVariables; { MWL }
for p := 0 to AParams.Count - 1 do
begin
case AParams[p].DataType of
ftString: DataType := otString;
ftDate,
ftTime,
ftDateTime: DataType := otDate;
ftFloat,
ftCurrency,
ftBCD: DataType := otFloat;
ftInteger,
ftSmallInt,
ftWord: DataType := otInteger;
ftBlob: DataType := otLongRaw;
ftOraBLOB: DataType := otBLOB;
ftMemo: DataType := otLong;
ftOraCLOB: DataType := otCLOB;
ftCursor: DataType := otCursor;
else
DataType := -1;
end;
if DataType >= 0 then
begin
if VariableIndex(AParams[p].Name) < 0 then { MWL }
DeclareVariable(AParams[p].Name, DataType);
if not (DataType in [otBLOB, otCLOB, otCursor]) then
SetVariable(AParams[p].Name, AParams[p].Value);
end;
end;
end;
 
Note that if you make this change, you can no longer control the variables from the Params of the TClientDataSet. This may not be important in your application, but you should be aware of it.

------------------
Marco Kalter
Allround Automations
 
Could you explain what you mean by controlling the variables from the client data set? As far as I can tell, the values applied to parameters on the client side are still being plugged in to the corresponding variables correctly on the server side.
 
Sorry for my brief and cryptic reply.

I was not talking about the values. If you add and remove Params in your TClientDataSet, these changes will be reflected in the Variables of the TOracleDataSet. If the Variables are not deleted (as a result of your change), the old Variables will persist even if you have deleted them from the Params.

------------------
Marco Kalter
Allround Automations
 
hmmm...what you say makes sense...

I guess it all boils down to coding style and philosophy. Since I do all business logic (a.k.a. SQL manipulations) on the server side rather than the client side, I'm passing the variables to the client and the client is only smart enough to populate the parameters accordingly (i.e. if the TClientDataSet has a marketid or userid (two common params throughout our app), then the client automatically knows to populate these values according to who is logged on and what market's data they're working with).

I suppose if one is putting logic in the client that manipulates SQL and sends it to the server, then the rules of the game as you pointed out do become important.

Thanks for pointing out that ramification of the change I made.
 
Back
Top