Page 1 of 1

Error compiling v 6.5.1 in Delphi 5 Enterprise

Posted: 25.11.2005, 17:58
by Zevang
Hi all,

My first time here, although I use Zeoslib for quite sometime now...

Problem now is that I've got a job transfer. I use Delphi 5 Enterprise Edition, and when I try to compile Zeos 6.5.1 I get an error concerning a Datautils.dcu missing.

Searching D5 installation, I saw no Datautils.dcu, but Datautil.dcu.
Yet, the package I was compiling (ZDbc) complained about a function that actually does not exist in the D5 original package (DecodeDateTime).

Am I doing something wrong? Do I have to use another version?

thanks in advance

Zevang

Posted: 28.11.2005, 13:14
by mdaems
Unfortunately Delphi 5 compatibility has been lost since the 2004 release of 6.5.1-alpha. You can use this 2004 release from sourceforge until the developers have fixed this unconvenience. (I do so and had not to much trouble in my simple appications) See other items in this forum.

Mark

Posted: 28.11.2005, 14:21
by zippo
Suggestion: Use a previous version.

Posted: 28.11.2005, 16:02
by Zevang
Thanks Mark and Zippo,

I'll try both suggestions.

Zevang

Posted: 29.11.2005, 15:42
by Zevang
Hi all.
It's just to tell you that I've got a working connection using the following:
-Delphi 5
-MySql 5
-Zeoslib 6.5.1 alpha (2004 edition)
Although not yet in production, I think it will be working stable.

thank you all

Zevang

Posted: 20.12.2005, 12:29
by A99
Dear developers! I have a quastion. Whether it's planned to solve in the near future a problem with Delphi 5 & Zeos 6.5.1? Please solve a problem or declare the termination of old Delphi releases support.

Posted: 20.12.2005, 16:42
by btrewern
It seems to me that the only file you need to change to get this working is ZDbcMySqlStatement.pas.

Replace

Code: Select all

function TZMySQLPreparedStatement.PrepareSQLParam(ParamIndex: Integer): string;
var
  Value: TZVariant;
  TempBytes: TByteDynArray;
  TempBlob: IZBlob;

  AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word;
begin
  TempBytes := nil;
  if InParamCount <= ParamIndex then
    raise EZSQLException.Create(SInvalidInputParameterCount);

  Value := InParamValues[ParamIndex];
  if DefVarManager.IsNull(Value) then
    if (InParamDefaultValues[ParamIndex] <> '') and
      StrToBoolEx(DefineStatementParameter(Self, 'defaults', 'true')) then
      Result := InParamDefaultValues[ParamIndex]
    else
      Result := 'NULL'
  else begin
    case InParamTypes[ParamIndex] of
      stBoolean:
        if SoftVarManager.GetAsBoolean(Value) then Result := '''Y'''
        else Result := '''N''';
      stByte, stShort, stInteger, stLong, stBigDecimal, stFloat, stDouble:
        Result := SoftVarManager.GetAsString(Value);
      stString, stBytes:
        Result := GetEscapeString(SoftVarManager.GetAsString(Value));
      stDate:
      begin
        DecodeDateTime(SoftVarManager.GetAsDateTime(Value),
          AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond);
        Result := '''' + Format('%0.4d-%0.2d-%0.2d',
          [AYear, AMonth, ADay]) + '''';
      end;
      stTime:
      begin
        DecodeDateTime(SoftVarManager.GetAsDateTime(Value),
          AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond);
        Result := '''' + Format('%0.2d:%0.2d:%0.2d',
          [AHour, AMinute, ASecond]) + '''';
      end;
      stTimestamp:
      begin
        DecodeDateTime(SoftVarManager.GetAsDateTime(Value),
          AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond);
        Result := '''' + Format('%0.4d-%0.2d-%0.2d %0.2d:%0.2d:%0.2d',
          [AYear, AMonth, ADay, AHour, AMinute, ASecond]) + '''';
      end;
      stAsciiStream, stUnicodeStream, stBinaryStream:
        begin
          TempBlob := DefVarManager.GetAsInterface(Value) as IZBlob;
          if not TempBlob.IsEmpty then
            Result := GetEscapeString(TempBlob.GetString)
          else Result := 'NULL';
        end;
    end;
  end;
end;
with

Code: Select all

function TZMySQLPreparedStatement.PrepareSQLParam(ParamIndex: Integer): string;
var
  Value: TZVariant;
  TempBytes: TByteDynArray;
  TempBlob: IZBlob;

  AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word;
begin
  TempBytes := nil;
  if InParamCount <= ParamIndex then
    raise EZSQLException.Create(SInvalidInputParameterCount);

  Value := InParamValues[ParamIndex];
  if DefVarManager.IsNull(Value) then
    if (InParamDefaultValues[ParamIndex] <> '') and
      StrToBoolEx(DefineStatementParameter(Self, 'defaults', 'true')) then
      Result := InParamDefaultValues[ParamIndex]
    else
      Result := 'NULL'
  else begin
    case InParamTypes[ParamIndex] of
      stBoolean:
        if SoftVarManager.GetAsBoolean(Value) then Result := '''Y'''
        else Result := '''N''';
      stByte, stShort, stInteger, stLong, stBigDecimal, stFloat, stDouble:
        Result := SoftVarManager.GetAsString(Value);
      stString, stBytes:
        Result := GetEscapeString(SoftVarManager.GetAsString(Value));
      stDate:
      begin
        DecodeDate(SoftVarManager.GetAsDateTime(Value),
          AYear, AMonth, ADay);
        Result := '''' + Format('%0.4d-%0.2d-%0.2d',
          [AYear, AMonth, ADay]) + '''';
      end;
      stTime:
      begin
        DecodeTime(SoftVarManager.GetAsDateTime(Value),
          AHour, AMinute, ASecond, AMilliSecond);
        Result := '''' + Format('%0.2d:%0.2d:%0.2d',
          [AHour, AMinute, ASecond]) + '''';
      end;
      stTimestamp:
      begin
        DecodeDate(SoftVarManager.GetAsDateTime(Value),
          AYear, AMonth, ADay);
        DecodeTime(SoftVarManager.GetAsDateTime(Value),
          AHour, AMinute, ASecond, AMilliSecond);
        Result := '''' + Format('%0.4d-%0.2d-%0.2d %0.2d:%0.2d:%0.2d',
          [AYear, AMonth, ADay, AHour, AMinute, ASecond]) + '''';
      end;
      stAsciiStream, stUnicodeStream, stBinaryStream:
        begin
          TempBlob := DefVarManager.GetAsInterface(Value) as IZBlob;
          if not TempBlob.IsEmpty then
            Result := GetEscapeString(TempBlob.GetString)
          else Result := 'NULL';
        end;
    end;
  end;
end;
and remove DateUtils from the Uses clause. Is that all that needs to be done? I haven't got Delphi 5 to check.

Regards,

Ben

Posted: 21.12.2005, 10:49
by A99
Sorry, but problem with Delphi 5 is not solved with DateUtils removing. ZeosDbo 6.5.1 uses some units (Variants, Types) not presented in Delphi 5 Enterprise. Some field (ftTimestamp) and variant types (varInt64, varWord, varLongWord) are not presented.

Posted: 21.12.2005, 13:25
by btrewern
A bit more complicated than I thought!

I think the Types unit was mostly extracted from some other units in Delphi 6 (To allow for Kylix compatibility) but Delphi 6 also overhauled lots of stuff to do with Variants so I think this may be a struggle.

Anyone else have any ideas?

Ben

Posted: 22.12.2005, 14:37
by mdaems
I think somebody with CVS-access, D5 and D6 should track back the incompatible changes and check if these changes can be implemented without the problematic units or with version-specific code.
I hope the dev team can find somebody who is willing to do this 'job from hell'. And indeed, if they don't they will have to take the decision and make it official.

Mark