473,609 Members | 1,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Local Access table in Oracle query

RLN
Re: Access 2003/Oracle 9i

I have an Access app that connects to an Oracle DB via OLEDB/VBA code
(no DSN or ODBC)

Queries against straight Oracle tables run fine.

For this query, however, the condition for finding DeptID's in the
Oracle table have to be filtered by a list of DeptID's found in
"tblDeptID" which is a simple local Access table containing one column
called "DeptID". There are 383 rows in this local table.

This code runs except for when I try and reference my local table.

Here is the code:
<begin code>
dim APVdb as Database
Set APVdb as CurrentDB()
strSQL = "SELECT A.MATCH_RULE_ID , " & _
"Count(A.MATCH_ RULE_ID) As CountofMATCH_RU LE_ID " & _
"FROM " &_
"PS_VCHR_MTCH_E XCPT A, " & _
"PS_VOUCHER_LIN E B " & _
"WHERE " & _
"A.BUSINESS_UNI T = B.BUSINESS_UNIT " & _
"AND A.VOUCHER_ID = B.VOUCHER_ID " & _
"AND A.VOUCHER_LINE_ NUM = B.VOUCHER_LINE_ NUM " & _
"AND A.PO_ID IN "
strSQL = strSQL & "(SELECT DISTINCT A.PO_ID " & _
"FROM PS_PO_LINE_DIST RIB A " & _
"WHERE A.DEPTID IN " & _
"(SELECT DEPTID from " & APVdb.tblDeptID & ")) " & _
"GROUP BY A.MATCH_RULE_ID "
<end code

Notice the next to the last line references my local table "tblDeptID" .
I have tried
- Currentdb.tblDe ptID
- dbo.tblDeptID
- Me.CurrentDB(Tb lDeptID)
- tblDeptID
...all to no avail.

I tried a pass-through query, but that does not work.

If you have an example where you are using a local lookup table of
values as a conditional select against an Oracle database, I would be
interested to see how it is done.

Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Sep 25 '06 #1
3 4343
If the Oracle table is linked, so it appears on the Tables tab along with
your local table, you should be able to use the query design view to link
them appropriately in a saved query. Try it with a saved query first, to at
least get it to work with limited criteria. Then use the Access-generated
SQL to assure your code is properly worded.

If need be, use the saved query every time, but change the criteria via code
as needed.
Sep 25 '06 #2
RLN

Victor,
Thanks for writing back.
When you have Oracle SQL and need to use data in a local Access table as
criteria for your Oracle extract, here is the solution via an ADO
recordset.

Just for reference, here was my dilemma:
All of the tables in my referenced query ('PO_ID', 'PO_VCHR',
'PS_VOUCHER_LIN E' et al) are Oracle tables. The only table that is a
local Access table is "tblDeptID' s") My application links to Oracle via
OLEDB using VBA code. There is no ODBC data source and no DSN.
To extract Oracle data I needed to use 300+ DeptIDs from a local as
criteria for the Oracle data extract. I collaborated talked with a
co-worker and he actually came up with a cool workaround. Nice job,
buddy!

The workaround consists of building the sub-SQL string that contains the
DeptID's, then incorporate that into the bigger Oracle string. Here is
the code to do it:

<begin code>
Dim rsDeptID As ADODB.Recordset
Dim strDeptIDSQL As String
Dim strDeptIDs As String

Set rsDeptID = New ADODB.Recordset
rsDeptID.Active Connection = CurrentProject. Connection
strDeptIDSQL = "Select * from tblDeptID order by DeptID"
rsDeptID.Open strDeptIDSQL 'we're using the currentproject connection
here as set above

Do While Not rsDeptID.EOF
'build your DeptID string here
strDeptIDs = strDeptIDs & " '" & rsDeptID.Fields (0).Value & "' ,"
rsDeptID.MoveNe xt
Loop

'trim off the last comma
strDeptIDs = Left(strDeptIDs , Len(strDeptIDs) - 1)

rsDeptID.Close
Set rsDeptID = Nothing
'you now have a string you can use in your Oracle SQL.

strSQL ="SELECT A.MATCH_RULE_ID , " & _
"Count(A.MATCH_ RULE_ID) As CountofMATCH_RU LE_ID " & _
"FROM " & _
"PS_VCHR_MTCH_E XCPT A, " & _
"PS_VOUCHER_LIN E B " & _
"WHERE " & _
"A.BUSINESS_UNI T = B.BUSINESS_UNIT " & _
"AND A.VOUCHER_ID = B.VOUCHER_ID " & _
"AND A.VOUCHER_LINE_ NUM = B.VOUCHER_LINE_ NUM " & _
"AND A.PO_ID IN "
strSQL = strSQL & "(SELECT DISTINCT A.PO_ID " & _
"FROM PS_PO_LINE_DIST RIB A " & _
"WHERE A.DEPTID IN " & _
"(" & strDeptIDs & ")) " & _
"GROUP BY A.MATCH_RULE_ID "
strSQLTestScrip t = strSQL
<end code>

Here, 'strDeptIDs' string (3rd line from the bottom in the above sql
string) would contain the DeptIDs retrieved above when the SQL string
was created via the ADO recordset going against the 300+ rows in local
table 'tblDeptID'. The ADO recordset runs in a tenth of a second
(tracked with a timer earlier) so there's no overhead to doing it this
way.

*** Sent via Developersdex http://www.developersdex.com ***
Sep 26 '06 #3
I don't use OLEDB as it does not allow one to make use of Access reports
and so have stuck with DAO and ODBC.

I'm pretty sure you simply can't combine operations with a local table
with your Oracle db. Remember that a local table is not Oracle, but is
an MS Jet object.

I would do what I think you've described in your follow up message:
create a string from an MS Jet query and then plop it into the where
clause of an Oracle statement.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Sep 26 '06 #4

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

Similar topics

1
2171
by: Peter Monica | last post by:
I am trying to calculate distance from a point entered by a user usng a function in Access in a query that calls tables in an Oracle database as well as in Access. I am getting the following message: Undefined function 'Distance' in expression. Here is the query: SELECT people.first_name , jobs.job
5
4341
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
2
2027
by: VMI | last post by:
I have a datatable with emplcodes and I need to extract, from my Access table, all records that contain an emplcode included in my datatable. In other words, I need to do a query that accesses a datatable and an access table. How can this be done? I can't load the Access table into a datatable; it's too much data. Thanks.
1
2054
by: pStan | last post by:
Nubie Question...I'm sure this is simple, but here goes anyway. I have a small VB.Net application that uses a local Access Database. I want that same local data replicated to an Internet web site so that I can use an ASP.NET page to work with the data. My DB and Application is not really big enough to mess with SQL server... QUESTION: What is the best way to sync my data to the web. I've tried the built in replication in Access and...
0
1286
by: Phil Haddock | last post by:
Hi, I'm converting an existing Access application to vb.net 2003. The application allows users to select a number of tables from an ODBC data source, and nominate names for each table to use in a local access table. When they press the button, it deletes any local tables that exist and recreates them using the new names, complete with current data. In Access I loop through the list of tables and substitute the appropriate
6
9893
by: Peter Neumaier | last post by:
Hi, I am trying to select some data through a stored procedure and would like to store the result in a local access table. Is that possible? Can somebody provide an example? Thanks&regards! Peter
5
16840
by: jun | last post by:
Friends, I need to insert around 13000 records from a sybase external DB to one of my local table in access. I have the connection string set up and everything works fine except for the execution time. It takes a lot of time to populate the local table because I have a recordset variable which loops through the 13000 records returned from the ADODB connection object and inserts one line after the other into the local table. Do you...
1
1836
by: palani12kumar | last post by:
Hi everybody. I'm in trouble in exporting a table from the Access to Oracle. I've created a table in Access and inserted nearly 20 records in that. Then i tried to move that into Oracle using the export option in the File menu. After copied the table into Oracle, The table that i moved from the Access has been listed in the list of tables in the oracle. But when i selected the the table to view its content in SQL using the SELECT query, i...
2
3580
by: KMEscherich | last post by:
Hi there, as I am totally new at this, can someone please give me detailed information on how to get Access table or query data to display onto a Dreamweaver page??? Thank you.
0
8091
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
8579
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...
1
8232
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,...
0
7024
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6064
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
5524
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
4032
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1403
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.