MS Access Pass Through Queries

32
S the of partnership power Evaluation Code Presenter: Dan DeBower Technical Consultant Systems & Computer Technology Corp. [email protected] Tuesday, April 10th -- 10:00am MS Access Pass Through Queries

description

MS Access Pass Through Queries. Presenter: Dan DeBower Technical Consultant Systems & Computer Technology Corp. [email protected] Tuesday, April 10th -- 10:00am. Session Rules of Etiquette. Please turn off your cell phone/beeper - PowerPoint PPT Presentation

Transcript of MS Access Pass Through Queries

Page 1: MS Access Pass Through Queries

S

theof partnership

power

Evaluation Code

Presenter:Dan DeBower

Technical ConsultantSystems & Computer Technology

[email protected]

Tuesday, April 10th -- 10:00am

MS AccessPass Through Queries

Page 2: MS Access Pass Through Queries

2

S

Evaluation Code

Session Rules of Etiquette

• Please turn off your cell phone/beeper

• If you must leave the session early, please do so as discreetly as possible

• Please avoid side conversation during the presentation

Thank you for your cooperation!

Page 3: MS Access Pass Through Queries

3

S

Evaluation Code

What you’ll learn

• After this session you will be able to:

• Connect Microsoft Access to SCT Banner via ODBC (Open Database Connectivity)

• Create a simple Pass-Through Query

• Increase the efficiency of your queries and reports

Page 4: MS Access Pass Through Queries

4

S

Evaluation Code

Topics

• ODBC: Open Database Connectivity

• Installing the ODBC driver

• Establish a DSN (Data Source Name)

• Pass-Through Queries

• WHY Pass-Through Queries?

• The Make-Table Query and Pass-Throughs

• Questions?

Page 5: MS Access Pass Through Queries

S

theof partnership

power

Evaluation Code

ODBC

Open Database Connectivity

Page 6: MS Access Pass Through Queries

6

S

Evaluation Code

ODBC

• Open Database Connectivity

• A standard application programming interface (or API) for accessing a wide range of databases

• Connects MS Access to an ODBC capable database (Specifically, Oracle)

• Originally released in 1992 by the SQL Access Group

Page 7: MS Access Pass Through Queries

7

S

Evaluation Code

ODBC Drivers

• The center of an ODBC connection

• Translates requests by an application into commands usable by the host database

• Utilizes ODBC defined Functions, Error Codes, and Data Types that are database independent

• Available from many vendors -- including Oracle, Microsoft, InterBase, OpenLink, Merant (Intersolv), Simba, and others

Page 8: MS Access Pass Through Queries

8

S

Evaluation Code

The ODBC Stack

D a ta S ou rceOracle

N e tw o rk T ra n sp o rtTCP/IP

D a ta b ase T ran spo rtSQL*Net or Net8

O D B C D r iv e r #1Oracle

D a ta S ou rceD B 2

N e tw o rk T ra n sp o rt

D a ta b ase T ran spo rt

O D B C D r iv e r #2D B 2

D a ta S ou rced B a se

N e tw o rk T ra n sp o rt

D a ta b ase T ran spo rt

O D B C D r iv e r #3d B a se

D r iv e r M a na ger(ODBC.dll)

O D B C A p p lica tion(Access , E xce l, C rysta l R e po r ts)

Page 9: MS Access Pass Through Queries

9

S

Evaluation Code

Choosing an ODBC Driver

• Oracle and Microsoft offer ODBC drivers for Oracle databases with no license fees

• Suggested driver: Oracle

• The Oracle and Microsoft drivers are more than sufficient for MS Access database linking and Pass-Through Queries

• Consider other vendors if you are developing applications that use ODBC directly

Page 10: MS Access Pass Through Queries

10

S

Evaluation Code

Installing an ODBC Driver

• The Oracle ODBC driver requires Oracle’s SQL*Net

• The TNSNames.ora file must be available to your workstation

• If you can connect SQL Plus to your target database, then SQL*Net is probably set up correctly

Page 11: MS Access Pass Through Queries

11

S

Evaluation Code

Installing an ODBC Driver

• Download an appropriate driver fromhttp://technet.oracle.com/software/download.htm

• Choose the driver that best matches your version of Oracle

• An exact match isn’t necessary, but you should match major releases (i.e. 7 or 8)

Page 12: MS Access Pass Through Queries

12

S

Evaluation Code

Installing an ODBC Driver

• Have SQLPlus installed on your workstation before installing the Oracle ODBC driver

• Allows testing of SQL*Net or Net8

• Valuable during Pass-Through development

• The Oracle 8 driver REQUIRES that the Oracle Universal Installer be previously installed on your workstation

Page 13: MS Access Pass Through Queries

13

S

Evaluation Code

Installing an ODBC Driver

• Install your driver

• Oracle 7

• Execute the downloaded file and start the included Oracle installer

• Oracle 8

• Execute the downloaded file and start the Oracle Universal Installer

Page 14: MS Access Pass Through Queries

14

S

Evaluation Code

Create a DSN (Data Source Name)

• Open ODBC Data Sources on the Windows Control Panel

• Select the System DSN tab

• Click Add...

• Select your driver from the list

• Configure your DSN

Page 15: MS Access Pass Through Queries

15

S

Evaluation Code

Configure your DSN

• Select a DSN name (like “Banner”)

• DSN names may be standardized at your site, so be sure to request guidance from your IT department or Computer Center

• Leave the other fields blank, they’ll be specified in your queries

Page 16: MS Access Pass Through Queries

16

S

Evaluation Code

Test your ODBC Connection

• Oracle includes a test program in their ODBC drivers called32-bit ODBC TEST

• Execute the test program, connect to your database, and enter a simple query

• If you have SQLPlus installed, test your connection there too!

Page 17: MS Access Pass Through Queries

17

S

Evaluation Code

A note about security

• ODBC is JUST AS SECURE as a connection through SQLPlus or another SQL editor

• Access to tables and other objects are granted to SQL and ODBC connections in the same way

• All (legitimate) access to Oracle is through SQL*Net or Net8 -- and they maintain security, not the ODBC driver

Page 18: MS Access Pass Through Queries

S

theof partnership

power

Evaluation Code

Pass-Through Queries

Page 19: MS Access Pass Through Queries

19

S

Evaluation Code

Create a Query

• The NEW button, on the database Queries tab.

• Or from the menu: Insert - Query

• From the wizard, select Design View

• And Close the show table window

• And Query - SQL Specific - Pass-Through

Page 20: MS Access Pass Through Queries

20

S

Evaluation Code

Prepare your query

• Create an ODBC Connection String

• In the Properties window enter a connection string:

ODBC;DSN=????;DBQ=????;UID=????;PWD=????;• DSN - your ODBC Data Source Name• DBQ - your Oracle database instance• UID - your Oracle UserID• PWD- your Oracle Password (Security???)

Page 21: MS Access Pass Through Queries

21

S

Evaluation Code

Prepare your query

• Create an ODBC Connection String

• If you leave out the Username and Password, Access will display a connection window

ODBC;DSN=Banner;DBQ=PROD;

Page 22: MS Access Pass Through Queries

22

S

Evaluation Code

Prepare your query

• Enter your SQL

• Remember - you can write and test your SQL queries in SQLPlus and then Copy-Paste from the SQL editor to the Pass-Through window!

Page 23: MS Access Pass Through Queries

23

S

Evaluation Code

Why Pass-Through Queries?

• Because you want to

• Because you need to

• Because you have to!

Page 24: MS Access Pass Through Queries

24

S

Evaluation Code

Why - Because you want to

• Pass-Throughs can increase the efficiency of your queries

• The SQL is passed directly to Oracle, Access doesn’t process the query

• SO Oracle SQL efficiency techniques can be applied to your Pass-Through!

Page 25: MS Access Pass Through Queries

25

S

Evaluation Code

Efficiency

• Include only the tables and where conditions that you absolutely must have

• Extra tables and wheres take time to process

• Order your where statements

• Put the most restrictive rules LAST

• Why? Oracle evaluates where statements from bottom to top!

Page 26: MS Access Pass Through Queries

26

S

Evaluation Code

Why - Because you need to

• Pass-Throughs aren’t processed by Access, so they’re not limited by Access!

• For instance, you can use Oracle Functions and Procedures in a Pass-Through that you couldn’t use elsewhere in Access

• HINT: If your Pass-Through Function or Procedure doesn’t work - enclose it in curly braces { } so Oracle can identify it

Page 27: MS Access Pass Through Queries

27

S

Evaluation Code

Why - Because you have to!

• The Microsoft Jet Database Engine that lies behind Access doesn’t respond well to Oracle databases with very large numbers of objects

• ODBC Table Linking -- the alternative to Pass-Throughs -- downloads data about all available Oracle objects, and that takes time

• The Linking process can take so long that it times out! You can’t use linking at all!

Page 28: MS Access Pass Through Queries

28

S

Evaluation Code

Make-Table Queries

• Using Access Make-Table Queries can simplify your use of Pass-Throughs

• A Make-Table will execute your query and store the results in a permanent Access table

• If you didn’t hard-code your password, you’ll be asked for it only once -- when you Make-Table

• Your Pass-Through won’t run unnecessarily!

Page 29: MS Access Pass Through Queries

29

S

Evaluation Code

Make-Table Queries

• First, create and test your Pass-Through

• Create a new query in Design View

• From the menu: Query - Make-Table Query…

• Select your query

• Double click * to include all your fields

Page 30: MS Access Pass Through Queries

30

S

Evaluation Code

An alternative to ODBC

• Oracle Objects for OLE (or Oracle Glue)

• Utilizes Microsoft OLE (Object Linking and Embedding), a set of APIs that produce compound, multipart documents

• Only available between Microsoft Visual Basic applications (Access, VB) and Oracle

• Strictly a programming interface (via Visual Basic)

Page 31: MS Access Pass Through Queries

31

S

Evaluation Code

Summary

• ODBC is much, much more than Table-Linking and Pass-Through Queries

• There are many reasons for using Pass-Throughs: Efficiency, flexibility, necessity…

• An understanding of SQL will give you more tools to use your data, and give you a better understanding of your database!

Page 32: MS Access Pass Through Queries

S

theof partnership

power

Evaluation Code

ExamplesAnd

Questions?

Don’t forget your evaluations!