473,396 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SQL PassThrough Question

My quesion is, can I use a look up, of sorts, in an SQL Pass Through
query?

My problem is I have built an application that uses pass through
queires to retrieve information from an Oracle source DB; rather than
build long SQL statements I have several simple pass through's that I
use to populate local tables then run the queries off those tables...

A typical and simplified SQL might be like ...

SELECT field1, field2, field3 from TABLE1 where Condition1 = 1234 and
Condition2 = 5678 and Condition3 = 91011;

Condition1, 2 and 3 will differentiate between which area of the
database is being interrogated. When the project asks for a different
area I seed a master copy of the application and change Condition1, 2
and 3 to suit.

There are a few different pass throughs on separate tables that differ
in which fields are being requested, but Condition1, 2 and 3 would
always be the same, is there anyway I can have the Pass Through query
'look up' Condition1, 2 and 3 without changing it for each pass
through every time I seed a new area? This would save time, as then I
would only have to change the 'look up' source once ...?

Hope that makes sense and thanks in advance ...

Luke
Sep 8 '08 #1
3 2781
On Mon, 8 Sep 2008 03:37:48 -0700 (PDT), lukethegooner
<lu***********@gmail.comwrote:

No, or at least not in the way one would with MDB's:
select * from sometable where somefield=[Give filter value:]
will not work, nor will:
select * from sometable where somefield=Forms!SomeForm!SomeControl
Reason is that a passthrough query is passed through, without
interpretation.
What WILL work is to create a querydef on the fly, with the right
where-clause. See CreateQueryDef in the help file.

-Tom.
Microsoft Access MVP
>My quesion is, can I use a look up, of sorts, in an SQL Pass Through
query?

My problem is I have built an application that uses pass through
queires to retrieve information from an Oracle source DB; rather than
build long SQL statements I have several simple pass through's that I
use to populate local tables then run the queries off those tables...

A typical and simplified SQL might be like ...

SELECT field1, field2, field3 from TABLE1 where Condition1 = 1234 and
Condition2 = 5678 and Condition3 = 91011;

Condition1, 2 and 3 will differentiate between which area of the
database is being interrogated. When the project asks for a different
area I seed a master copy of the application and change Condition1, 2
and 3 to suit.

There are a few different pass throughs on separate tables that differ
in which fields are being requested, but Condition1, 2 and 3 would
always be the same, is there anyway I can have the Pass Through query
'look up' Condition1, 2 and 3 without changing it for each pass
through every time I seed a new area? This would save time, as then I
would only have to change the 'look up' source once ...?

Hope that makes sense and thanks in advance ...

Luke
Sep 8 '08 #2
On 8 Sep, 14:34, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
No, or at least not in the way one would with MDB's:
What WILL work is to create a querydef on the fly, with the right
where-clause. See CreateQueryDef in the help file.
Thanks for your input Tom, greatly appreciated, will look into your
suggestion ...

Luke
Sep 9 '08 #3
You can most certainly change the sql of the pass through query.

eg:
Dim qdfPass As DAO.QueryDef
Dim rst As DAO.Recordset
Set qdfPass = CurrentDb.QueryDefs("MyPass")
qdfPass.SQL = "exec sp_myProc"
qdfPass.Execute

The above is used to send "raw" commands to sql server.

And, if you want to return data, simply go:

qdfPass.SQL = "SELECT field1, field2, field3 " & _
"FROM TABLE1 " & _
"WHERE Condition1 = 1234 " & _
"AND Condition2 = 5678 " & _
"AND Condition3 = 91011;"
Set rst = qdfPass.OpenRecordset

Now, if you looking to do the above for a report, or form, I would actually
create a linked table to the stored view on the server side, and simply use
the "where" clause to open the report.

eg:
dim strWhere as string

strWhere = "Condition1 = 1234 " & _
"AND Condition2 = 5678 " & _
"AND Condition3 = 91011"

docmd.OpenReport "ReportName",acViewPreview,,strWhere

I see little if any benefit to use/build a sql pass-through query here. I
think using a simple where clause is the least amount of work (and I find
performance to that linked view works VERY well, as good as a pass-though
anyway). So, simply bind the report to that linked view on the server. Just
thinking about this, binding the report to the pass-though should also
accept the where clause also

So, the give the "where" clause idea if this is a report. And, if it is
reocrdset processing code, then the above querydef example is just fine
also...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Nov 17 '08 #4

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

Similar topics

1
by: Ron_A | last post by:
NewBee, Got some clues from some databases written using passthrough queries but don't understanc the case... statements. Is there any books anywhere that wiill include help on the syntax required...
7
by: Bri | last post by:
Greetings, I have a Passthrough Query to SQL Server that I want to know the RecordsAffected, but it always returns 0. This worked perfectly when it was an Access Query on the ODBC linked...
1
by: hromberg | last post by:
I have a set of passthrough queries that rely on a temporary table in SQL and currently I am dealing with this by creating a passthrough that builds the table and leaves the connection open for an...
1
by: KayC | last post by:
Hi I use Access2002 I have created a simple form with 3 parameter UserID, Password & Database When a user enters values into these text boxes a passthrough query to a Sybase database is envoked...
2
by: TjS | last post by:
Hellow, i am quite new to access, but i am searching for a visual basic script to change the connection string for all the passthrough queries which are in my access database. These passthrough...
2
by: RoadrunnerII | last post by:
Hi All I am new to this forum and still learning MS Access. Hoping this is the right place to ask If not please let me know! Looking for some help with the SQL statements in Access 2003 with the...
1
by: BharathP | last post by:
Hi, I need to transfer data of one of the table in DB2 to Microsoft Access. I tried using DBOP data source using Configuration assistant in DB2 and SQL passthrough in Microsoft Access. I think I'm...
10
by: raphfrk | last post by:
Is there any way to pass a variable list to a function, so as to act as a passthrough? for example: void new_printf ( char *buf , ... ) { va_list vlist; <modify buf slightly>
3
by: ryanjkoffler | last post by:
Hello... I have a single passthrough query where the possiblity for it to return zero records exists. If zero records will be returned, is there a way to add some logic that will catch this and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.