TPgParam raises assertion error when cast as TParam

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
yozey
Posts: 32
Joined: Sat 17 Jan 2009 14:41

TPgParam raises assertion error when cast as TParam

Post by yozey » Mon 18 May 2009 22:57

Hi, even though TPgParam descends from TDAParam which descends from TParam, using the following code raises and access violation with LoadFromFile

Code: Select all

TParam(MyParam).LoadFromFile('somefile', ftBlob); //where MyParam is a TParam
The assertion raised is that the Datatype is not supported. Shouldn't the above method work for a TParam descendant?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 19 May 2009 07:07

TDAParam works with BLOBs in different way then TParam. You cannot use TParam for the ftBlob data type. Some methods in TParam are not virtual and cannot be overriden. So you should use TDAParam or TPgParam.

yozey
Posts: 32
Joined: Sat 17 Jan 2009 14:41

Post by yozey » Wed 20 May 2009 11:17

My issue was a routine that filled TParams with values supplied. Since the routine uses the parent class to allow for usage with most TParam descendants, I could not now enforce a TPgParam/TDaParam as it would limit it to DevArt components.

I found a workaround however using the Assign procedure of TParam.

Code: Select all

var
  Pr: TParam;
begin
  Pr := TParam.Create(nil);
  try
    Pr.Assign(Param); // assign original param properties
    { Fill Pr with some data from supplied stream }
    Param.Assign(Pr); // Reassign data to supplied TParam
  finally
    Pr.Free;
  end;
This has so far worked with 2 different supplied TParam descendants.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 21 May 2009 07:35

This workaround shoud work correctly.

Post Reply