C
CevinMoses
I am using Access 97 as a front end to an Oracle server in order to customize
the information I can get out of it to create better reports than what the
availalbe frontend offers.
My pass-through queries have worked well, but due to my lack of experience
with complex queries, I have been writing queries that reference queries that
reference queries, rather than one complex query that gets it all done in one
shot. I have been trying to learn to write one, but with little success,
though I did pull off a pass-through union query seen below as subquery2. I
have dumbed them down more and more and still get the same error:
[Oracle][ODBC][Ora]ORA-00936: missing expression (#936)
Rather than give you the dumbed down version, here is the full code. I
thought it best to build two subqueries in the WHERE clause. The first
selects data relavent to when the products were made. The second subquery
combines two tables of grading data, one table stores data for pieces that
are acceptable, and the other table stores data for those that are not.
Together, they make up data with the grading results each piece receives on
the inspection end prior to being put in a box and shipped out. Both
subquery1 and subquery2 have successfully worked on their own, and I have
used a local query in MS-Access to join the two. However, I would much
rather have the Oracle server do the processing for me.
SELECT
subquery1.NP_SERIAL,
subquery1.NC_CLOCK,
subquery1.NC_FOREMAN_CLOCK,
subquery1.DP_CAST,
subquery1.DATEPART('h',[DP_CAST]),
subquery1.NC_SHIFT,
subquery1.CP_JOB_LOCATION,
subquery1.NP_PART,
subquery2.[INSPECTION_DATE],
subquery2.[GRADE],
subquery2.[DEFECT]
FROM
(SELECT
NP_SERIAL,
NC_CLOCK,
NC_FOREMAN_CLOCK,
DP_CAST,
NC_SHIFT,
CP_JOB_LOCATION,
NP_PART
FROM
TBVN66
WHERE
(CP_JOB_LOCATION LIKE 'MC7') and
(np_part Like '%2214%') and
(dp_cast between to_date('120106', 'mmddyy') and to_date('010107',
'mmddyy'))) subquery1,
(SELECT
NP_SERIAL,
DP_STOCK_CHANGE AS "INSPECTION_DATE",
CP_GRADE AS "GRADE",
CP_DEFECT AS "DEFECT",
NP_PART,
CP_POSTING_EVENT,
NP_REWORK_CYCLE,
QP_QUANTITY
FROM
TBVN62
WHERE
(NP_PART LIKE '%2214%') AND
(DP_STOCK_CHANGE > TO_DATE('120106', 'mmddyy')) AND
(NP_REWORK_CYCLE = '0') AND
(QP_QUANTITY = '1') AND
(CP_POSTING_EVENT LIKE '!_%' ESCAPE '!')
UNION
SELECT
NP_SERIAL,
DP_CULL AS "INSPECTION_DATE",
CP_GRADE AS "GRADE",
CP_DEFECT AS "DEFECT",
NP_PART,
CP_POSTING_EVENT,
NP_REWORK_CYCLE,
QP_QUANTITY
FROM
TBVN58
WHERE
(np_part Like '%2214%') AND
(DP_CULL > to_date('120106', 'mmddyy')) AND
(NP_REWORK_CYCLE = '0') AND
(QP_QUANTITY = '1') AND
(CP_POSTING_EVENT LIKE '!_%' ESCAPE '!')) subquery2
WHERE
subquery1.NP_SERIAL = subquery2.NP_SERIAL
Please let me know what more I can provide that will help.
Thanks in advance!
Cevin
the information I can get out of it to create better reports than what the
availalbe frontend offers.
My pass-through queries have worked well, but due to my lack of experience
with complex queries, I have been writing queries that reference queries that
reference queries, rather than one complex query that gets it all done in one
shot. I have been trying to learn to write one, but with little success,
though I did pull off a pass-through union query seen below as subquery2. I
have dumbed them down more and more and still get the same error:
[Oracle][ODBC][Ora]ORA-00936: missing expression (#936)
Rather than give you the dumbed down version, here is the full code. I
thought it best to build two subqueries in the WHERE clause. The first
selects data relavent to when the products were made. The second subquery
combines two tables of grading data, one table stores data for pieces that
are acceptable, and the other table stores data for those that are not.
Together, they make up data with the grading results each piece receives on
the inspection end prior to being put in a box and shipped out. Both
subquery1 and subquery2 have successfully worked on their own, and I have
used a local query in MS-Access to join the two. However, I would much
rather have the Oracle server do the processing for me.
SELECT
subquery1.NP_SERIAL,
subquery1.NC_CLOCK,
subquery1.NC_FOREMAN_CLOCK,
subquery1.DP_CAST,
subquery1.DATEPART('h',[DP_CAST]),
subquery1.NC_SHIFT,
subquery1.CP_JOB_LOCATION,
subquery1.NP_PART,
subquery2.[INSPECTION_DATE],
subquery2.[GRADE],
subquery2.[DEFECT]
FROM
(SELECT
NP_SERIAL,
NC_CLOCK,
NC_FOREMAN_CLOCK,
DP_CAST,
NC_SHIFT,
CP_JOB_LOCATION,
NP_PART
FROM
TBVN66
WHERE
(CP_JOB_LOCATION LIKE 'MC7') and
(np_part Like '%2214%') and
(dp_cast between to_date('120106', 'mmddyy') and to_date('010107',
'mmddyy'))) subquery1,
(SELECT
NP_SERIAL,
DP_STOCK_CHANGE AS "INSPECTION_DATE",
CP_GRADE AS "GRADE",
CP_DEFECT AS "DEFECT",
NP_PART,
CP_POSTING_EVENT,
NP_REWORK_CYCLE,
QP_QUANTITY
FROM
TBVN62
WHERE
(NP_PART LIKE '%2214%') AND
(DP_STOCK_CHANGE > TO_DATE('120106', 'mmddyy')) AND
(NP_REWORK_CYCLE = '0') AND
(QP_QUANTITY = '1') AND
(CP_POSTING_EVENT LIKE '!_%' ESCAPE '!')
UNION
SELECT
NP_SERIAL,
DP_CULL AS "INSPECTION_DATE",
CP_GRADE AS "GRADE",
CP_DEFECT AS "DEFECT",
NP_PART,
CP_POSTING_EVENT,
NP_REWORK_CYCLE,
QP_QUANTITY
FROM
TBVN58
WHERE
(np_part Like '%2214%') AND
(DP_CULL > to_date('120106', 'mmddyy')) AND
(NP_REWORK_CYCLE = '0') AND
(QP_QUANTITY = '1') AND
(CP_POSTING_EVENT LIKE '!_%' ESCAPE '!')) subquery2
WHERE
subquery1.NP_SERIAL = subquery2.NP_SERIAL
Please let me know what more I can provide that will help.
Thanks in advance!
Cevin