Link to home
Start Free TrialLog in
Avatar of Jeff
JeffFlag for United States of America

asked on

Access Pass Through Query rounding off ending zeros

We are using MS Access 2010 to run some SQL pass through queries against our iSeries DB2 db. While it is working really well and provides a nice front end to DB2 it's not without it's quirks which may end up being a deal breaker for using Access. For some reason Access is dropping/rounding off zeros at the end of our cost field.

select decimal(fficst, 10, 2) as cost
from mytable

or

select cast(fficst as decimal (10, 2))
from mytable

results in :
20 instead of 20.00
10.5 instead of 10.50
1.4 instead of 1.40

Running the code directly on the iSeries gives the correct results so I'm comfortable the SQL is good. The field can be formatted in a report to display properly, but it would be nice to just see the result display correctly according to the SQL.
SOLUTION
Avatar of Member_2_2484401
Member_2_2484401
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeff

ASKER

Working with DB2 pass through queries in Access seems to prevent me from having the design view that you normally get when working with regular queries in an Access DB. My design view is SQL so I can't set various properties through GUI; everything must take place in the SQL code. If I were pushing the results to a table I could get around it, but the method I figured out below gives me the exact result that I need without storing the data in Access and in the iSeries. I can simply run my Pass Through queries at any moment, spit out a report or file in variety of formats for a variety of uses.

The article Use Microsoft Access to interact with your DB2 data gave me the idea to give Access a try. The biggest problem I've experienced was finding an inexpensive front end that I can manipulate to do most everything that I want with DB2 SQL.

An excellent product for working with DB2 directly on the iSeries is File Access from Oasis Software International. While we own a license and it is unbelievably easy and useful to use, I find that it has limitations.

While I am hitting some bumps with DB2 Pass Through queries in Access I haven't found any show stoppers like I have in iSeries Nav Run SQL Script and I find STRSQL a little cumbersome. Also, I have some experience with VBA as well so Macros and Email functionality is readily available.

This gives me the result that I'm looking for. I can now easily push my results out to whatever I want...

select cast(cast(fficst as decimal (10,2)) as char(10)) as Cost
from mytable

Open in new window


I'm not really sure who to award the points to.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You probably don't need to do pass through queries at all.   I would always start with an Access query against linked tables.  If that is slow and the query contains one or more joins, I would create a view.  Of course if you are creating a reporting app, you don't n to worry about keeping your queries updateable so pass through queries and stored procedures are also options but I suggest always starting with the "Access way" as the path of least resistance.