Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-10-03
10
Medium Priority
?
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 85

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 200 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 1100 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

704 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