Subject | SQLWhere Items ??? |
---|---|
Author | Alan McDonald |
Post date | 2003-04-27T00:10:22Z |
I don't seem to understand when/how SQLWhereItems get added so that they are
active. The snippet below shows what I thought would be valid. I've even
tried invalidating the sql and refreshing, but no matter what the sequence,
I only ever get the SQL being executed.. i.e. without the where clauses. If
I add the where clauses directly into the SQL, it works fine. What do need
to do to take advantage of the SQLWhereItems add - I need to provide a lot
definition to the where section - it's be nice not to worry about whether
I've added a 'WHERE' and 'AND' stuff.
If I use the onPrepareSQL, I don;t have valid values for building the where
clause, so I have to use this sort of sequence.
Can someone enlighten me?
Thanks
Alan
IB_CMembers.Open;
while not IB_CMembers.Eof do begin
IB_CAdverts.SQL.Clear;
IB_CAdverts.SQL.Add('SELECT ID, LINKTOMEMBER, LINKTOROLECATEGORY,
LINKTOLOCATION, ADREF, JOBTITLE, ');
IB_CAdverts.SQL.Add('SHORTDESCRIPTION, JOBDESCRIPTION, CONTACTPERSON,
EMPTIME, EMPSTATUS, LOCATION, ');
IB_CAdverts.SQL.Add('INCFOOTER, FOOTER, SUBMITDATE, GOLIVE, EXPIRY,
ADACTIVE ');
IB_CAdverts.SQL.Add('FROM ADVERTISEMENTS');
IB_CAdverts.SQLWhereItems.Add('LINKTOLOCATION IN
('+IB_CMembers.FieldByName('JSLOCATION').AsString+')');
IB_CAdverts.SQLWhereItems.Add('LINKTOROLECATEGORY IN
('+IB_CMembers.FieldByName('JSEMPROLE').AsString+')');
if (IB_CMembers.FieldByName('JSEMPTIME').AsString<>'either') then
IB_CAdverts.SQLWhereItems.Add('EMPTIME =
'''+IB_CMembers.FieldByName('JSEMPTIME').AsString+'''');
if (IB_CMembers.FieldByName('JSEMPSTATUS').AsString<>'either') then
IB_CAdverts.SQLWhereItems.Add('EMPSTATUS =
'''+IB_CMembers.FieldByName('JSEMPSTATUS').AsString+'''');
// IB_CAdverts.InvalidateSQL;
// IB_CAdverts.Refresh;
IB_CAdverts.Open;
while not IB_CAdverts.Eof do begin
inc(matches);
IB_CAdverts.Next;
end;
IB_CAdverts.Close;
IB_CMembers.Next;
end;
IB_CMembers.Close;
active. The snippet below shows what I thought would be valid. I've even
tried invalidating the sql and refreshing, but no matter what the sequence,
I only ever get the SQL being executed.. i.e. without the where clauses. If
I add the where clauses directly into the SQL, it works fine. What do need
to do to take advantage of the SQLWhereItems add - I need to provide a lot
definition to the where section - it's be nice not to worry about whether
I've added a 'WHERE' and 'AND' stuff.
If I use the onPrepareSQL, I don;t have valid values for building the where
clause, so I have to use this sort of sequence.
Can someone enlighten me?
Thanks
Alan
IB_CMembers.Open;
while not IB_CMembers.Eof do begin
IB_CAdverts.SQL.Clear;
IB_CAdverts.SQL.Add('SELECT ID, LINKTOMEMBER, LINKTOROLECATEGORY,
LINKTOLOCATION, ADREF, JOBTITLE, ');
IB_CAdverts.SQL.Add('SHORTDESCRIPTION, JOBDESCRIPTION, CONTACTPERSON,
EMPTIME, EMPSTATUS, LOCATION, ');
IB_CAdverts.SQL.Add('INCFOOTER, FOOTER, SUBMITDATE, GOLIVE, EXPIRY,
ADACTIVE ');
IB_CAdverts.SQL.Add('FROM ADVERTISEMENTS');
IB_CAdverts.SQLWhereItems.Add('LINKTOLOCATION IN
('+IB_CMembers.FieldByName('JSLOCATION').AsString+')');
IB_CAdverts.SQLWhereItems.Add('LINKTOROLECATEGORY IN
('+IB_CMembers.FieldByName('JSEMPROLE').AsString+')');
if (IB_CMembers.FieldByName('JSEMPTIME').AsString<>'either') then
IB_CAdverts.SQLWhereItems.Add('EMPTIME =
'''+IB_CMembers.FieldByName('JSEMPTIME').AsString+'''');
if (IB_CMembers.FieldByName('JSEMPSTATUS').AsString<>'either') then
IB_CAdverts.SQLWhereItems.Add('EMPSTATUS =
'''+IB_CMembers.FieldByName('JSEMPSTATUS').AsString+'''');
// IB_CAdverts.InvalidateSQL;
// IB_CAdverts.Refresh;
IB_CAdverts.Open;
while not IB_CAdverts.Eof do begin
inc(matches);
IB_CAdverts.Next;
end;
IB_CAdverts.Close;
IB_CMembers.Next;
end;
IB_CMembers.Close;