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

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?
huangs3Asked:
Who is Participating?
 
GRayLCommented:
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
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
 
GRayLCommented:
The only way to use a stored Oracle function in a remote database from Access is via a SQL Pass-Through query..
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
rheitzmanCommented:
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
 
GRayLCommented:
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
 
huangs3Author Commented:
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
 
rheitzmanCommented:
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
 
GRayLCommented:
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
 
huangs3Author Commented:
Thank you for everybody's idea, we end up with using a database View to call the database function, and the issue solved.
0
 
GRayLCommented:
Thanks, glad to help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.