DOA Driver unable to handle blob fields

delphi

(Christen Blom Dahl) #1

Current implementation of procedure uDADOADriver is unable to handle Blob fields. The correct implementation to handle those fields should be:

procedure SetDataSetParams(Params: TDAParamCollection; DataSet: TDataSet; aList: TThreadList);
var
  I: Integer;
  Ds: TOracleDataSet;
  ParamIndex, OraType: Integer;
  Name: string;
  LOB: TLOBLocator;
begin
  Ds := TOracleDataSet(DataSet);
  if Ds.Variables.Count > Params.Count then
    for I := Ds.VariableCount - 1 downto 0 do
      if Params.ParamByName(Ds.VariableName(I)) = nil then
        Ds.DeleteVariable(Ds.VariableName(I));

  for I := 0 to Params.Count - 1 do
  begin
    ParamIndex := Ds.VariableIndex(Params[I].Name);
    Name := HandleSqlName(Params[I].Name, Params[I].ParamType);
    OraType := DataTypeDaToOra(Params[I].DataType);
    // New Param
    if ParamIndex = -1 then Ds.DeclareVariable(Name, OraType);
    // Changed Param
    if (ParamIndex > -1) and (Ds.VariableType(ParamIndex) <> DataTypeDaToOra(Params[I].DataType)) then begin
      Ds.DeleteVariable(Params[I].Name);
      Ds.DeclareVariable(Name, OraType);
    end;
    if Params[i].DataType in [datWideString] then begin
      Ds.DeclareVariableCharSet(Name, ocfNational, ocsUTF16);
    end;
    // Set value
    if Params[I].DataType in [datXml, datWideMemo, datMemo] then begin
      if Params[I].DataType = datMemo then begin
        LOB := TLOBLocator.CreateTemporary(Ds.Session, otCLOB, True);
        Lob.AsString := Params[I].Value;
      end
      else begin
        LOB := TLOBLocator.CreateTemporary(Ds.Session, otNCLOB, True);
        LOB.CharSetID := ocsUTF16;
        Lob.AsWideString := Params[I].Value;
      end;
      aList.Add(LOB);
      Ds.SetComplexVariable(Name,Lob);
    end
    else if Params[I].DataType = datBlob then begin
      LOB := TLOBLocator.CreateTemporary(Ds.Session, otBLOB, True);
      if not (VarIsNull(Params[I].Value) or VarIsEmpty(Params[I].Value)) then
        Lob.AsString := Params[I].Value;
      aList.Add(LOB);
      Ds.SetComplexVariable(Name, Lob);
    end
    else if Params[I].DataType = datBoolean then
      Ds.SetVariable(Name, Integer(Params[I].Value))
    else
      Ds.SetVariable(Name, Params[I].Value);
  end;
end;

(RemObjects) #2

Thanks, logged as bugs://81206


(RemObjects) #3

bugs://81206 got closed with status fixed.