473,756 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q:Access Parameterized Query to Oracle?

comp.databases. ms-access,

I want to know how to use Oracle views with session variables in
Access.
The parameterised views in access, are migrated to views with per
session
variables.

The open questions:
How to display a resultset
How to handle Oracle exceptions

Closed questions:
How to call a stored procedure from DAO.
How to call a stored procedure from ado and then display a view in a
form.
Using a cache to get the same session.

[Sample database setup]

(I have an Oracle backgroud)

The open questions:
How to display a resultset
*************** ***********
I am not sure how to display a recordset that is created in VBA.

How to handle Oracle exceptions
*************** *************** *
Oracle handles errors by 'exceptions',
I am not sure how to handle them in Access.

Closed questions:

What I have been able to do is:

[My session variables have an API, but basically one needs to call a
stored procedure/function to set/get them]

How to call a stored procedure from DAO
*************** *************** ********

Set session variables over DAO/ODBC:
where 'QUERYEXAMPLE:i nput_name' references a variable and 'smith' is
the value
to set.

call to set string via dao
Function SetVal() As Boolean
Dim db As Database
Set db = DBEngine.Worksp aces(0).Databas es(0)
Set qitem = db.CreateQueryD ef("")
qitem.Connect = "ODBC;DSN=o92;U ID=scott;PWD=ti ger"
qitem.ReturnsRe cords = False
qitem.ODBCTimeo ut = 15
qitem.SQL = "CALL
omwb_emulation. utilities.setva rchar2('QUERYEX AMPLE:input_nam e','smith')"
qitem.Execute
Set qitem = Nothing
SetVal = True
End Function
How to call a stored procedure from ado and then display a view in a
form;
using ado/oledb
*************** *************** *************** *************** ***********

How to bind Microsoft Access forms to ADO recordsets:
http://support.microsoft.com/default...b;en-us;281998

looks like adodb.recordset s bound to forms are read only.
The following is based on the Microsoft information with nformation
fille in
about using odbc to reach the oracle database with the views. The same
session
is used to set the parameter and then select from the view to populate
the
form.

Option Compare Database

Private Sub Form_Open(Cance l As Integer)
Dim cn As ADODB.Connectio n
Dim rs As ADODB.Recordset
Dim strConnection As String
Dim setstring As ADODB.Command
Dim param1 As ADODB.Parameter
Dim param2 As ADODB.Parameter

strConnection = "ODBC;DSN=o92;U ID=northwindalt ;PWD=oracle"
'Create a new ADO Connection object
Set cn = New ADODB.Connectio n

With cn
.Provider = "MSDASQL"
.Properties("Da ta Source").Value = strConnection
.Open
End With

'Create an instance of the ADO Recordset class, and
'set its properties

Set setstring = New ADODB.Command
With setstring
.ActiveConnecti on = cn
.CommandText = "omwb_emulation .utilities.setv archar2"
.CommandType = adCmdStoredProc
End With

Set param1 = setstring.Creat eParameter(, adVarChar, adParamInput,
100, "QUERYEXAMPLE:i nput_name")
setstring.Param eters.Append param1

Set param2 = setstring.Creat eParameter(, adVarChar, adParamInput,
100, "smith")
setstring.Param eters.Append param2

setstring.Execu te

Set setstring = Nothing

Set rs = New ADODB.Recordset
With rs
Set .ActiveConnecti on = cn
.Source = "SELECT * FROM queryexample"
.LockType = adLockOptimisti c
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.Open
End With

'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rs
Set rs = Nothing
Set cn = Nothing
End Sub

Private Sub Form_Unload(Can cel As Integer)
'Close the ADO connection we opened
Dim cn As ADODB.Connectio n
Set cn = Me.Recordset.Ac tiveConnection
cn.Close
Set cn = Nothing
End Sub

Using a cache to get the same session.
*************** *************** *****
The thing is there is a timeout

The Microsoft Jet database engine uses the ODBC entries as follows.

Initialization Settings for Microsoft Jet-connected ODBC Databases
The \HKEY_LOCAL_MAC HINE\Software\M icrosoft\Jet\4. 0\Engines\ODBC folder
contains initialization settings for the Microsoft Jet database engine.

ConnectionTimeo ut The number of seconds a cached connection can remain
idle
before timing out. The default is 600 (values are of type REG_DWORD).

Sample database setup
*************** ****

example:
table example1.
ID, name, telephone
1,jones,321
2,smith,123

query
query queryexample:
Parameters [input name] text;
select telephone from example1 where name=[input name];

becomes in oracle
CREATE OR REPLACE FORCE VIEW queryexample AS
SELECT telephone
FROM example1
WHERE name = (SELECT
omwb_emulation. utilities.getva rchar2('QUERYEX AMPLE:input_nam e') FROM
dual)

which can be called from Oracle sqlplus:

SQL> begin
2
omwb_emulation. utilities.setva rchar2('QUERYEX AMPLE:input_nam e','smith');
3 end;
4 /

SQL> select * from queryexample;

TELEPHONE
--------------------------------------------------
123

Nov 13 '05 #1
0 3028

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6078
by: gary b | last post by:
Hello When I use a PreparedStatement (in jdbc) with the following query: SELECT store_groups_id FROM store_groups WHERE store_groups_id IS NOT NULL AND type = ? ORDER BY group_name
3
23457
by: Jon Ole Hedne | last post by:
My Access 2002-application need to work with tables from both Oracle and Access. To solve this, I want to run some querys on three views in Oracle and import the results into temporary Access-tables. I have tried this: conn.Provider = "Microsoft.Jet.OLEDB.4.0" conn.ConnectionString = "data source=" & datafil & ";Jet OLEDB:Database Password=" conn.Open datafil
4
2054
by: bhbgroup | last post by:
I have a query on one large table. I only add one condition, i.e. a date (the SQL reads like 'where date > parameterdate'. This query is rather quick if 'parameterdate' is either explicitly written into the query or if it is a 'normal' access parameter value that is entered during the query. If I however create a separate parameter table that contains nothing but the date I want to use in the query and then refer to this table (the query...
8
4041
by: Alfonso Esteban Gonzalez Sencion | last post by:
I am trying to use Access as a front end for extracting information from an Oracle database. I started using linked tables but I am getting a very curious behaviour. When I consult the linked table in access, the total number of records is OK but some records appear several times and some records do not appear at all. It seems as if access or the ODBC drivers returns several times the same record and skips some of the records, curiosly...
5
4353
by: premmehrotra | last post by:
I am using Microsoft Access 2000 and Oracle 9.2.0.5 on Windows 2000. When I export a table from Access to Oracle using ODBC I get error: ORA 972 identifier too long I think the error is because one or more columns in Access table are longer than 30 characters. My question is how one can overcome this problem. I also see several column names which have /, ? or spaces in name
8
9637
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query work from
12
5284
by: zwasdl | last post by:
Hi, I'm using MS Access to query against Oracle DB via ODBC. Is it possible to use HINT in Access? Thanks, Wei
0
2219
by: Tom | last post by:
Looking for some help with stored procedure call issues. Conceptually, I need to pass a data structure as the sole parameter to the Oracle stored procedure. Sounds simple enough....but how? First, looking at this from the stored procedure side, I see a few things the procedure can do: 1) receive a CLOB/BLOB 2) receive a user defined data type 3) receive multiple params, one for each distinct data element
5
7234
by: jonceramic | last post by:
Hi All, I started developing in Access, and people took notice and so we're starting to migrate into our corporate's bigger Oracle system. I'll still be using my developed Access front ends, but will be migrating my back ends to Oracle ODBC. 1. Does anyone have recommendations for books or web resources for general rules/guidelines/help on doing this? I haven't found a good
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.