jn1480
asked on
SQL Passthrough Query Error: ORA-00936: Missing Expression (#936)
Hey guys -
I wrote a relatively simple query in MSAccess 2010 against an ODBC linked Oracle table.
It was taking a bit long to run, so I opted to convert it to a SQL Pass Through query, and run it that way to gain the advantage of it running on the server as opposed to my desktop.
However, while the query did run as a standard Make Table query in Access, it now errors out as SQL Pass Through query in Access.
The SQL is in the code below.
The error is as follows:
=========
ODBC--call failed.
[Oracle][ODBC][Ora]ORA-003 96: missing expression
(#936)
OK Help
=========
I tried running it with single quotes instead of # for the dates, and without a WHERE statement at all, but same error…
Any thoughts?
I wrote a relatively simple query in MSAccess 2010 against an ODBC linked Oracle table.
It was taking a bit long to run, so I opted to convert it to a SQL Pass Through query, and run it that way to gain the advantage of it running on the server as opposed to my desktop.
However, while the query did run as a standard Make Table query in Access, it now errors out as SQL Pass Through query in Access.
The SQL is in the code below.
The error is as follows:
=========
ODBC--call failed.
[Oracle][ODBC][Ora]ORA-003
(#936)
OK Help
=========
I tried running it with single quotes instead of # for the dates, and without a WHERE statement at all, but same error…
Any thoughts?
SELECT XBRADMIN_POS_SKU_TAB.STORENUM AS Store, XBRADMIN_POS_SKU_TAB.TRANSDATE, XBRADMIN_POS_SKU_TAB.TRANSNUM, XBRADMIN_POS_SKU_TAB.REGNUM, XBRADMIN_POS_SKU_TAB.QUANTITY, XBRADMIN_POS_SKU_TAB.LINENUM, Int([CASHIERNUM]) AS SalesID, XBRADMIN_POS_SKU_TAB.ITEM, XBRADMIN_POS_SKU_TAB.MERCH_DEPT, XBRADMIN_POS_SKU_TAB.MERCH_CLASS INTO 2010T_POSSkuTab
FROM XBRADMIN_POS_SKU_TAB
WHERE (((XBRADMIN_POS_SKU_TAB.STORENUM)<3000) AND ((XBRADMIN_POS_SKU_TAB.TRANSDATE) Between #7/31/2011# And #8/6/2011#) AND ((XBRADMIN_POS_SKU_TAB.ORGID)=1) AND ((XBRADMIN_POS_SKU_TAB.DIVISION)=1) AND ((XBRADMIN_POS_SKU_TAB.TRANSSTAT)="COMPLETE") AND ((XBRADMIN_POS_SKU_TAB.TRANSTYPE)<>"RETURN") AND ((XBRADMIN_POS_SKU_TAB.TRAINING_FLAG)="N") AND ((XBRADMIN_POS_SKU_TAB.VOID_CODE)=0))
ORDER BY XBRADMIN_POS_SKU_TAB.STORENUM, XBRADMIN_POS_SKU_TAB.TRANSDATE, XBRADMIN_POS_SKU_TAB.TRANSNUM, XBRADMIN_POS_SKU_TAB.REGNUM, XBRADMIN_POS_SKU_TAB.QUANTITY;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The " Int([CASHIERNUM]) " also probably needs changing. Look at "TO_NUMBER()"
I'm not an Oracle guy, but SQL Server uses a different date format than Access (at least it used to) and would not accept dates parameters formatted as #7/31/2012#. It has been a while, but I believe the Oracle syntax requires that you replace the # with a '
ASKER
Thanks guys!
I've got it down to this, and am at least getting a different error now:
=========
ODBC--call failed.
[Oracle][ODBC][Ora]ORA-009 03: invalid table name
(#903)
OK Help
=========
I've got it down to this, and am at least getting a different error now:
=========
ODBC--call failed.
[Oracle][ODBC][Ora]ORA-009
(#903)
OK Help
=========
CREATE TABLE 2010T_POSSkuTab
AS
SELECT STORENUM AS Store, TRANSDATE, TRANSNUM, REGNUM, QUANTITY, LINENUM, CASHIERNUM AS SalesID, ITEM, MERCH_DEPT, MERCH_CLASS
FROM XBRADMIN.POS_SKU_TAB
WHERE (((STORENUM)<3000) AND ((TRANSDATE) Between '7/31/2011' And '8/6/2011') AND ((ORGID)=1) AND ((DIVISION)=1) AND ((TRANSSTAT)="COMPLETE") AND ((TRANSTYPE)<>"RETURN") AND ((TRAINING_FLAG)="N") AND ((VOID_CODE)=0))
ORDER BY STORENUM, TRANSDATE, TRANSNUM, REGNUM, QUANTITY;
Again, I'm not an Oracle guy, but if you are just trying to return a set of records, try dropping the
CREATE TABLE 2010T_POSSkuTab
AS
CREATE TABLE 2010T_POSSkuTab
AS
1. Try a simpler name in the CREATE TABLE xxx. All uppercase. If you want mixed case, you'll have to put the name in quotes.
2. Use '2011JUL31' and '2011AUG06' for the dates. '2011-JUL-31' etc. should actually work with both SQL Server and Oracle.
2. Use '2011JUL31' and '2011AUG06' for the dates. '2011-JUL-31' etc. should actually work with both SQL Server and Oracle.
it seems you have a dot in the table name
...FROM XBRADMIN.POS_SKU_TAB
in you previous postings it was
...FROM XBRADMIN_POS_SKU_TAB
...FROM XBRADMIN.POS_SKU_TAB
in you previous postings it was
...FROM XBRADMIN_POS_SKU_TAB
I've requested that this question be deleted for the following reason:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
ASKER
Sorry about the abandoning - I figured it out - below is my fix:
=========
When Microsoft Access converts a standard query to SQL Pass-Through, it generally does not take into account what type of database it will be going against and does not update the SQL Query language accordingly.
To write a SQL Pass-Through query against an Oracle database, you will need to update your SQL to Oracle friendly SQL
=========
EXAMPLES
———
If you were converting the following Query to a SQL Pass-Through query:
—
SELECT XBRADMIN_POS_SKU_TAB.STORE NUM AS Store, XBRADMIN_POS_SKU_TAB.TRANS DATE, XBRADMIN_POS_SKU_TAB.TRANS NUM, XBRADMIN_POS_SKU_TAB.REGNU M, XBRADMIN_POS_SKU_TAB.QUANT ITY, XBRADMIN_POS_SKU_TAB.LINEN UM, Int([CASHIERNUM]) AS SalesID, XBRADMIN_POS_SKU_TAB.ITEM, XBRADMIN_POS_SKU_TAB.MERCH _DEPT, XBRADMIN_POS_SKU_TAB.MERCH _CLASS INTO 2010T_POSSkuTab
FROM XBRADMIN_POS_SKU_TAB
WHERE (((XBRADMIN_POS_SKU_TAB.ST ORENUM)<30 00) AND ((XBRADMIN_POS_SKU_TAB.TRA NSDATE) Between #7/31/2011# And #8/6/2011#) AND ((XBRADMIN_POS_SKU_TAB.ORG ID)=1) AND ((XBRADMIN_POS_SKU_TAB.DIV ISION)=1) AND ((XBRADMIN_POS_SKU_TAB.TRA NSSTAT)="C OMPLETE") AND ((XBRADMIN_POS_SKU_TAB.TRA NSTYPE)<>" RETURN") AND ((XBRADMIN_POS_SKU_TAB.TRA INING_FLAG )="N") AND ((XBRADMIN_POS_SKU_TAB.VOI D_CODE)=0) )
ORDER BY XBRADMIN_POS_SKU_TAB.STORE NUM, XBRADMIN_POS_SKU_TAB.TRANS DATE, XBRADMIN_POS_SKU_TAB.TRANS NUM, XBRADMIN_POS_SKU_TAB.REGNU M, XBRADMIN_POS_SKU_TAB.QUANT ITY;
—
You would first need to update the fields (dates, remove double quotes on where criteria, etc…) to look like this:
—
SELECT STORENUM AS Store, TRANSDATE, TRANSNUM, REGNUM, QUANTITY, LINENUM, CASHIERNUM AS SalesID, ITEM, MERCH_DEPT, MERCH_CLASS
FROM XBRADMIN.POS_SKU_TAB
WHERE (((STORENUM)<3000) AND ((TRANSDATE) Between '31-jul-2011' And '6-aug-2011') AND ((ORGID)=1) AND ((DIVISION)=1) AND ((TRANSSTAT)='COMPLETE') AND ((TRANSTYPE)<>'RETURN') AND ((TRAINING_FLAG)='N') AND ((VOID_CODE)=0))
ORDER BY STORENUM, TRANSDATE, TRANSNUM, REGNUM, QUANTITY;
=========
When Microsoft Access converts a standard query to SQL Pass-Through, it generally does not take into account what type of database it will be going against and does not update the SQL Query language accordingly.
To write a SQL Pass-Through query against an Oracle database, you will need to update your SQL to Oracle friendly SQL
=========
EXAMPLES
———
If you were converting the following Query to a SQL Pass-Through query:
—
SELECT XBRADMIN_POS_SKU_TAB.STORE
FROM XBRADMIN_POS_SKU_TAB
WHERE (((XBRADMIN_POS_SKU_TAB.ST
ORDER BY XBRADMIN_POS_SKU_TAB.STORE
—
You would first need to update the fields (dates, remove double quotes on where criteria, etc…) to look like this:
—
SELECT STORENUM AS Store, TRANSDATE, TRANSNUM, REGNUM, QUANTITY, LINENUM, CASHIERNUM AS SalesID, ITEM, MERCH_DEPT, MERCH_CLASS
FROM XBRADMIN.POS_SKU_TAB
WHERE (((STORENUM)<3000) AND ((TRANSDATE) Between '31-jul-2011' And '6-aug-2011') AND ((ORGID)=1) AND ((DIVISION)=1) AND ((TRANSSTAT)='COMPLETE') AND ((TRANSTYPE)<>'RETURN') AND ((TRAINING_FLAG)='N') AND ((VOID_CODE)=0))
ORDER BY STORENUM, TRANSDATE, TRANSNUM, REGNUM, QUANTITY;
ASKER
Please see my final comment, and award points to fomoruto
Thanks!
Thanks!
ASKER
It really ended up only being about query syntax.
The SQL Language MSAccess converted the query to for pass-through, was inaccurate when going against Oracle.
I corrected the syntax and all was well -
See my final comment for answer/notes.
The SQL Language MSAccess converted the query to for pass-through, was inaccurate when going against Oracle.
I corrected the syntax and all was well -
See my final comment for answer/notes.
Just so you understand, Access does not "convert" the SQL in your query when you convert it to a pass-through query, you have to do that.