qryParts.Close;
with qryParts.SQL do
begin
Clear;
Add('SELECT P.SUPPLIER, P.PREFIX');
Add(', CASE WHEN (P.PREFIX = C.EVENT) THEN
C.ENGINEER_ID');
Add(' ELSE C.SQA_ENGINEER_ID');
Add(' END AS ASSIGNED_SQA_ENGINEER');
Add('FROM PART P');
Add('JOIN (SELECT DISTINCT SUPPLIER, SQA_ENGINEER_ID,
ENGINEER_ID, EVENT');
Add(' FROM CONTACTS');
Add(' WHERE CONTACT_TYPE = ''SQAPQC'') C ON C.SUPPLIER =
P.SUPPLIER');
end;
qryParts.Open;
At the last statement I receive the following error statement.
"Project **** raised an exception class EDBEngine error with message
'Invalid use of keyword'.
Token: When
Line Number: 2"
I have run the sql statement independently in the query analyzer and it runs
well.
Can you please tell me how I can get this sql statement to work. Thanks
-- M
--
Alain Quesnel
alainqs...@compuserve.com
"Srinivas Chundi" <nospam...@hotmail.com> wrote in message
news:3e97...@newsgroups.borland.com...
--
Robert Cerny
http://codecentral.borland.com/codecentral/ccWeb.exe/author?authorid=18355
"Srinivas Chundi" <nospam...@hotmail.com> wrote in message
news:3e97...@newsgroups.borland.com...
-- M
"Robert Cerny" <robert.q...@neosys.xrs.qwe.si> wrote in message
news:b7e0c1...@neosys.xrs.si...
"Srinivas Chundi" <nospam...@hotmail.com> wrote in message
news:3e9a...@newsgroups.borland.com...
Also the double quotes are non-standard but that might be ok if you're using
a non-standard server.
Regards,
Greg Gaughan www.thinksql.co.uk
"Srinivas Chundi" <nospam...@hotmail.com> wrote in message
news:3e97...@newsgroups.borland.com...
SELECT P.SUPPLIER, P.PREFIX,
CASE
WHEN P.PREFIX = C.EVENT THEN C.ENGINEER_ID // <- removed paranthesis
ELSE C.SQA_ENGINEER_ID
END AS ASSIGNED_SQA_ENGINEER
FROM PART P
JOIN ( SELECT DISTINCT SUPPLIER, SQA_ENGINEER_ID,
ENGINEER_ID, EVENT
FROM CONTACTS
WHERE CONTACT_TYPE = 'SQAPQC') C ON C.SUPPLIER = P.SUPPLIER
OR
SELECT P.SUPPLIER, P.PREFIX,
CASE P.PREFIX // <- moved input value
WHEN C.EVENT THEN C.ENGINEER_ID
ELSE C.SQA_ENGINEER_ID
END AS ASSIGNED_SQA_ENGINEER
FROM PART P
JOIN ( SELECT DISTINCT SUPPLIER, SQA_ENGINEER_ID,
ENGINEER_ID, EVENT
FROM CONTACTS
WHERE CONTACT_TYPE = 'SQAPQC') C ON C.SUPPLIER = P.SUPPLIER
"Srinivas Chundi" <nospam...@hotmail.com> wrote in message
news:3e97...@newsgroups.borland.com...
"Greg Gaughan" <be...@thinksql.co.uk> wrote in message
news:3e9b...@newsgroups.borland.com...
Find a tool you can use to see the SQL being sent to the server. For
example I use OracleMonitor.EXE which comes with DOA a
set of components for accessing oracle databases. This will let
you see if the query reaching the database is what you think it is.
Brian Evans
"Srinivas Chundi" <nospam...@hotmail.com> wrote in message
news:3e9ee15f$1...@newsgroups.borland.com...
--
Alain Quesnel
alainqs...@compuserve.com
"Brian Evans @promaxis.com>" <brian<nospam> wrote in message
news:3e9efd50$1...@newsgroups.borland.com...
Thats more at the database level. There is usually also a client level tool
that also shows some information on the results returned. For example
going through the BDE you could use the Borland supplied SQL Monitor
to see what SQL was being sent to any BDE database. Tool is usually
specific to that delphi database connection component set.
If such a tool can't be found then the MS SQL profiler can do it but
you end up with a lot of other stuff thrown in and no info if any
query was successful, how many rows modified or returned etc.
Brian Evans