🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.database
Article #241

D5, TBDEDataSet.Lookup, VarArray with 1 element

#241
From: Jesper Andersen
Date: Fri, 21 Jun 2002 08:41
39 lines
1830 bytes
Hi 

I had a problem with TBDEDataSet.Locate using a vararray with one
element as KeyValues. I got an "invalid variant conversion error", so
I started investigating. Stepping through the code I got to
TBDEDataSet.CreateLookupFilter. In DBTabls.pas:5268 it says:

if Fields.Count = 1 then
begin
  Node := Filter.NewCompareNode(TField(Fields[0]), coEQ, Values);
  Expr := Node;
end else
  for I := 0 to Fields.Count - 1 do
  begin
    Node := Filter.NewCompareNode(TField(Fields[I]), coEQ, Values[I]);
    if I = 0 then
      Expr := Node else
      Expr := Filter.NewNode(enOperator, coAND, Unassigned, Expr,
Node);
  end;

With one element in the array, Values is of type vararray of variant.
Later in the code it is converted to a string, resulting in the
exception.

Wouldn't it be better if 
  if Fields.Count = 1 then

was changed to

 if not IsVarArray(Values) then

This way, arrays with 1 element will work.

Regards,
Jesper Andersen
Developer
L-R Software A/S
Denmark
Technical Details
Message-ID: <752757e8.0206210041.6d04546@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 115d96,ac1f9117241d8392,start
X-Google-Attributes: gid115d96,public
X-Google-ArrivalTime: 2002-06-21 01:41:06 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
From: jka@lrsoftware.dk (Jesper Andersen)
Newsgroups: borland.public.delphi.database
Subject: D5, TBDEDataSet.Lookup, VarArray with 1 element
Date: 21 Jun 2002 01:41:06 -0700
Organization: http://groups.google.com/
Lines: 39
Message-ID: <752757e8.0206210041.6d04546@posting.google.com>
NNTP-Posting-Host: 212.130.11.198
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1024648866 12323 127.0.0.1 (21 Jun 2002 08:41:06 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 21 Jun 2002 08:41:06 GMT