Solved

Access 2003: any easy way to use stored Oracle functions as part of regular Access SELECT query?

Posted on 2008-10-03
10
216 Views
Last Modified: 2013-11-27
We are supporting a Microsoft Access application that accesses Oracle data through ODBC Linked Tables. Access Select queries are used to select data from the linked Oracle tables for use in reports. Changes in the underlying Oracle database have resulted in the requirement to use an custom Oracle function to return a value that used to be available as a column.

Attempts to call the Oracle function in the SELECT clause of the Access Select query SQL statement resulted in errors. In an attempt to work around this, we converted the Access Select query to a SQL Pass-through query and the Oracle function can be called successfully.

Is a SQL Pass-through query the only way to call a stored Oracle function as part of a SELECT clause, or is this also possible in a regular Access Select query?
0
Comment
Question by:huangs3
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 50 total points
ID: 22638154
If you're using the CurrentProject.Connection then I believe it is ... you could try building your own connection to the database and use that, but even then I believe you'll run into issues.

To me, a better solution would be to build a Stored Proc on the server that handled this for you and simply returned a formatted/filtered recordset to you. Build it such that is will accept input parameters for filters and such, and let the server deal with it.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 22638262
The only way to use a stored Oracle function in a remote database from Access is via a SQL Pass-Through query..
0
 
LVL 7

Assisted Solution

by:rheitzman
rheitzman earned 275 total points
ID: 22638270
From the Access side the Pass-Through query is the primary method. You can develop your query and then in the last pass add the Oracle Function and turn it into a pass though. You might experience date comparison problems however.

You should be able to use an Oracle View and link to as you would a table.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 22638317
But Linking has all the overhead of delivering all the data to Access and then Access has to determine the answer.  A pass through only delivers the answer.  
0
 

Author Comment

by:huangs3
ID: 22668705
We encounter an issue of using Pass-through. There is one Access query using the form parameters (like [Forms]![InputForm]![begin-Date] ) in its where-clause, and needs to call the database function at the same time.

I couldn't find a way to let a pass-through function use the form parameter, what is the best way for me to handle this in Access?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 44

Accepted Solution

by:
GRayL earned 175 total points
ID: 22670139
And now Oracle does not have any exposure to the Access mdb which sent the Pass-Through query.  I don't know if you can use any Access functions like Date() in a Pass-Through.  If you can, then maybe by creating a function which obtains the value from the open form might be a solution.  With a form frmDate open with a textbox named tbxDateset (Format property set to short date) in which you have entered =Date()

eg.  Instead of Date() in the Pass-through use GetDate()

Public Function GetDate() AS Date
  GetDate = Forms!frmDate!tbxDate
End Function

It all depends on whether Access will process the function before passing the query.  That failing, it is probably possible to create a pass-through in VBA and use code to send it -  just trying to think outside the box.
0
 
LVL 7

Assisted Solution

by:rheitzman
rheitzman earned 275 total points
ID: 22674414
I think if you use an Oracle view to resolve the Oracle function problem the view can be linked to from Access. The Access side link would support Access functions and references to any other objects Access can utilize with a local table.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 22674463
If an Oracle View can utilize Oracle functions to reduce the size of the dataset sent to Access and Access in turn can utilize its objects to further reduce the dataset to match all the remaining criteria, then you have a solution - probably saying the same thing ;-)
0
 

Author Comment

by:huangs3
ID: 22768410
Thank you for everybody's idea, we end up with using a database View to call the database function, and the issue solved.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 22768498
Thanks, glad to help
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now