TVariables.Assign in OracleType


Code:
procedure TVariables.Assign(Source: TPersistent);
...
        buftype  := 0;
        case VarType(TParams(Source)[i].Name) of
         varBoolean,
            varByte,
        varSmallInt,
         varInteger
...

Propose to replace

Code:
VarType(TParams(Source)[i].Name)

to

Code:
TParams(Source)[i].DataType
 

Code:
case TParams(Source)[i].DataType of
//        case VarType(TParams(Source)[i].Name) of
         ftBoolean,
           ftBytes,
        ftSmallInt,
         ftInteger: buftype := otInteger;
          ftCurrency,
          ftFloat: buftype := otFloat;
            ftTime,
            ftDateTime,
            ftDate: buftype := otDate;
       ftWideString: buftype := otPLSQLString;
          ftString : buftype := otString;
          ftFmtMemo: buftype := otSubst;  // 25-11-2005
          ftADT    : buftype := otCursor; // 12-08-2008
        end;

propose to replace message

Code:
raise Exception.Create('Unsupported variable type');

to

Code:
raise Exception.Create('Variable ' + TParams(Source)[i].Name + ' has Unsupported variable type');

 
Marco, your software works as follows:

Code:
var
  ods : TOracleDataSet;
  Params : TParams;
  i : integer;
  s : string;
  param : TParam;
begin
  ods := TOracleDataSet.Create(Nil);
  Params := TParams.Create(Nil);
  param := Params.CreateParam(ftInteger,  'int',  ptInput);
  param := Params.CreateParam(ftString,   'str',  ptInput);
  param := Params.CreateParam(ftDateTime, 'date', ptInput);
  ods.Variables.Assign(Params);
  for i := 0 to ods.VariableCount-1 do
  begin
    s := s + ods.VariableName(i) + '-' + IntToStr(ods.VariableType(i)) + #13;
  end;
  ShowMessage(s);
          //  :int-5
          //  :str-5
          // :date-5
 
Back
Top