🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1263

SQL Query

#1263
From: Nigel
Date: Tue, 07 Sep 2004 15:00
58 lines
3787 bytes
Hi,
I have an ADOQuery component in my application which is used as a common
component for all my SQL queries.  I set the SQL Command and assign it to
the ADOQuery component and open the query.  Everthing works fine, but I have
one query that works fine the first time the application is launched after
that the problem starts.

First SQL Command

SELECT WeldsDone.Project, WeldsDone.StampNo1, Welders.Initials,
Welders.Surname, Count(WeldsDone.DateWelded) AS CountOfDateWelded,
Sum(IIf([WeldsDone].[WeldFailure]<>'Fitter',1,0)) AS Rejected,
Sum(IIf([WeldsDone].[WeldFailure]<>'Fitter',WeldsDone.FailLength,0)) AS
SumOfFailLength, Sum(Welds.NB1) AS SumOfNB1
FROM ((WeldsDone INNER JOIN Welders ON WeldsDone.StampNo1 = Welders.StampNo)
INNER JOIN Welds ON (WeldsDone.Project = Welds.Project) AND
(WeldsDone.Drawing = Welds.Drawing) AND (WeldsDone.Location =
Welds.Location) AND (WeldsDone.WeldType = Welds.WeldType) AND
(WeldsDone.Sheet = Welds.Sheet) AND (WeldsDone.WeldNo = Welds.WeldNo)) INNER
JOIN ProjectDetails ON WeldsDone.Project = ProjectDetails.Project
WHERE ProjectDetails.Active AND (WeldsDone.RBSR=True OR WeldsDone.RASR=True)
GROUP BY WeldsDone.Project, WeldsDone.StampNo1, Welders.Initials,
Welders.Surname
ORDER BY WeldsDone.Project, WeldsDone.StampNo1

I then run the following SQL command

SELECT WeldsDone.Project, WeldsDone.StampNo1, Welders.Initials,
Welders.Surname, Count(WeldsDone.DateWelded) AS CountOfDateWelded,
Sum(IIf([WeldsDone].[WeldFailure]<>'Fitter',1,0)) AS Rejected,
Sum(IIf([WeldsDone].[WeldFailure]<>'Fitter',WeldsDone.FailLength,0)) AS
SumOfFailLength, Sum(Welds.NB1) AS SumOfNB1
FROM ((WeldsDone INNER JOIN Welders ON WeldsDone.StampNo1 = Welders.StampNo)
INNER JOIN Welds ON (WeldsDone.Project = Welds.Project) AND
(WeldsDone.Drawing = Welds.Drawing) AND (WeldsDone.Location =
Welds.Location) AND (WeldsDone.WeldType = Welds.WeldType) AND
(WeldsDone.Sheet = Welds.Sheet) AND (WeldsDone.WeldNo = Welds.WeldNo)) INNER
JOIN ProjectDetails ON WeldsDone.Project = ProjectDetails.Project
WHERE ProjectDetails.Project = :PROJECT AND (WeldsDone.RBSR=True OR
WeldsDone.RASR=True)
GROUP BY WeldsDone.Project, WeldsDone.StampNo1, Welders.Initials,
Welders.Surname
ORDER BY WeldsDone.Project, WeldsDone.StampNo1

When I reassign the first SQL Command again to the query the result is still
as if I assigned the second SQL Command.  You will notice that the two
commands are identical except in the WHERE clause "WHERE
ProjectDetails.Active AND (WeldsDone.RBSR=True OR WeldsDone.RASR=True)" vs
"WHERE ProjectDetails.Project = :PROJECT AND (WeldsDone.RBSR=True OR
WeldsDone.RASR=True)".  The secong SQL WHERE clause uses a parameter which
may be the problem but I have tried several things like clearing parameters
before assigning the SQL Command to no avail.

Totally Stumped
Please help
Nigel Hussey

P.S. The SQL Command is originally generated by Access were if works fine.
Technical Details
Message-ID: <413dcc40@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,e605b67116941c9,start
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Nigel" <nhussey@gltame.com>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: SQL Query
Date: Tue, 7 Sep 2004 17:00:58 +0200
Lines: 60
Organization: Grinaker - LTA
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 196.38.60.194
Message-ID: <413dcc40@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1094569024 196.38.60.194 (7 Sep 2004 07:57:04 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail