ghkweon / dwscript

Automatically exported from code.google.com/p/dwscript
0 stars 0 forks source link

Improve parameter handling in dwsUIBDatabase #414

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The loop in AssignParameters should be

   for i := 0 to Length(params) - 1 do begin
      p := PVarData(@params[i]);

currently the params are "off by one" as the TUIBQuery.Params.As*[] array 
starts from 0 (zero), current code assumes 1 (one).

Also add "FQuery.Prepare(True)" call to the TdwsUIBDataSet constructor: 

constructor TdwsUIBDataSet.Create(db : TdwsUIBDataBase; const sql : String; 
const parameters : TData);
begin
   FDB:=db;
   inherited Create(db);
   FQuery:=TUIBQuery.Create;
   try
      FQuery.FetchBlobs:=True;
      FQuery.Transaction:=db.FTransaction;
      FQuery.SQL.Text:=sql;
      FQuery.Prepare(True);
      AssignParameters(FQuery, parameters);
      FQuery.Open;

this helps to convert parameters to correct SQL types.

Original issue reported on code.google.com by ain.val...@gmail.com on 4 Jun 2013 at 1:50

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r2152.

Original comment by zar...@gmail.com on 4 Jun 2013 at 2:50