Board index » delphi » TQuery result different from DBE Result

TQuery result different from DBE Result

Hi All,

The following SQL statment returns 0 when run from a TQuery component.
The exact same statement returns 875 when run in the Database Explorer.
In addition, if I don't create static fields for the TQuery object then
it won't recognize "LocalMail" as a vaild field name.  What's going on?

SELECT COUNT(*) AS LocalMail
FROM tblLogEntries LE
WHERE (LE.EventNumber = 1000) AND
LE.MessageID NOT IN
(SELECT LE2.MessageID
FROM tblLogEntries LE2
WHERE LE2.EventNumber = 1013)

USING:
Delphi4 (Update 3)
Paradox 7 tables
Win98

Thanks,
Chuck

 

Re:TQuery result different from DBE Result


On Sat, 03 Jul 1999 08:56:39 -0600, Haron <ha...@XwebaccessX.net>
wrote:

Quote
>The following SQL statment returns 0 when run from a TQuery component.
>The exact same statement returns 875 when run in the Database Explorer.

Weird.  AFAIK Database Explorer is written in Delphi and uses a TQuery
to perform its task just the same...

Quote
>In addition, if I don't create static fields for the TQuery object then
>it won't recognize "LocalMail" as a vaild field name.  What's going on?

Perhaps a memory problem.  The query is a bit memory intensive because
of the subquery.  You can try to increase the memory settings in
BDEAdmin to see if this helps.

Jan

Re:TQuery result different from DBE Result


Quote
On Sat, 03 Jul 1999 08:56:39 -0600, Haron <ha...@XwebaccessX.net> wrote:
>The following SQL statment returns 0 when run from a TQuery component.
>The exact same statement returns 875 when run in the Database Explorer.
>In addition, if I don't create static fields for the TQuery object then
>it won't recognize "LocalMail" as a vaild field name.  What's going on?

>SELECT COUNT(*) AS LocalMail
>FROM tblLogEntries LE
>WHERE (LE.EventNumber = 1000) AND
>LE.MessageID NOT IN
>(SELECT LE2.MessageID
>FROM tblLogEntries LE2
>WHERE LE2.EventNumber = 1013)

Column correlation names in local SQL statements should be recognized fine
within Delphi, and in fact are essential to use the FieldByName method of
the TQuery. Had you previously defined other persistent field objects for
this particular TQuery? Does the Fields property (presumably with an index
of zero) find the field? What does the FieldCount property of the TQuery
return after activating this TQuery? You are activating the TQuery with the
Open method and not the ExecSQL method, right?

Try the same operation without the COUNT function. Does the query, using
these WHERE clause conditions, return records when executed fro a TQuery?

Also, double-check the database to which the TQuery is pointing. Do this
just to make sure it is using the same table as was used in the Database
Explorer utility.

==========================================================================
Steve Koterski                  "Computers are useless. They can only give
Technical Publications          you answers."
Borland                                       -- Pablo Picasso (1881-1973)
http://www.borland.com/techpubs/delphi

Other Threads