Solved

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

Posted on 2008-10-03
10
218 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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
 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

823 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