Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Articles
Search: 

Configuring Your System for Access to Oracle
Mark McCasland, January 1, 2001
More and more we are seeing larger companies migrating their databases to Oracle. Usually this is done for data warehousing and for publishing data to the Internet or a company intranet. What I attempt to explain in this FAQ is how to configure a Windows 3.1 or Win95 workstation to access the Oracle...
More and more we are seeing larger companies migrating their databases to Oracle. Usually this is done for data warehousing and for publishing data to the Internet or a company intranet. What I attempt to explain in this FAQ is how to configure a Windows 3.1 or Win95 workstation to access the Oracle server and database. The assumption that I do make is that the Oracle DBA has properly installed Oracle and the SQL*Net "listener" on the Oracle server.

Each workstation that will be used to access Oracle needs the following:

  • appropriate ODBC Drivers installed. Recommend using MS ODBC Drivers (32bit) which are available free. See http://www.microsoft.com/data/download2.htm for downloading information.
  • a data source added through the ODBC Administrator
  • TCP/IP address (either a permanently assigned or a floating IP address assigned to the workstation by your Network Operating System)
  • SQL*Net

The next assumption is that SQL*Net version 2.x is being used. You will need software from Oracle which is usually delivered on a CD-ROM - "Oracle Products for Windows/Win95/NT." The title should be close to what I have quoted, but the products absolutely have to be for the client and not the server. A SQL*Net license has to be purchased for each computer it is installed on. You may also consider purchasing a SQL*Plus license for each developer and for those "advanced" users who may be placed in charge of managing the database/data. If your client workstations do not all have CD-ROM drives, you can load the Oracle CD-ROM on a server and map to it from each workstation in order to install the necessary software.

Oracle will install most of its products in directory structure under C:\ORAWIN for Windows 3.1 and C:\ORAWIN95 for Win95. The C:\ORAWIN(95)\BIN directory is referred to as the Oracle home directory and must be in the workstation PATH environment.

In the C:\ORAWIN(95)\NETWORK\ADMIN directory is where the TNSNAMES.ORA file must be located. This file contains information on how SQL*Net connects to your data source. A sample of this file can be found in the SAMPLES subdirectory under ADMIN. Keep in mind, this is real client-server, and it does not matter where the server is or where the client is. I access an Oracle database in North Carolina from my client workstation in Dallas. As long as you (the client) are on the same side as any server firewall, you can connect to the Oracle server. If you are "outside" your organization (e.g., from a home computer), you could get a permanent TCP/IP address assigned to your computer that falls under your organization's domain. This effectively puts you on the same side of the firewall and gets you access to the server.

A semi-real example of a TNSNAMES.ORA file is given below (a few key data elements have been changed to protect the identity and location of the real database).


################
# Filename......: tnsnames.ora
# Name..........: 
# Date..........: 2-24-97
################
MyDbName = 
 (DESCRIPTION =
   (ADDRESS_LIST =
     (ADDRESS =
       (COMMUNITY = TCP.DOMAIN.GOV)
       (PROTOCOL = TCP)
       (HOST = 999.99.999.99)
       (PORT = 1234)
     )
   )
   (CONNECT_DATA = 
     (SID = sidw)
   )
 )


I do not come up with the formatting of this file, I just copy-and-paste it in place from the original file.

Creating an Oracle data source is done through the ODBC Administrator. Start the ODBC Administrator and click the Add button. From the list box, select the Oracle driver. In the form that comes up next, you will enter the Data Source Name (DSN) and Description. The DSN should be a short name. The Description, while needed, is not critical to the connection; just fill in with descriptive enough information so you know what database you are connecting to. The 3rd field is the user ID (optional). The 4th field is the SQL*Net Connect String which, in my example TNSNAMES.ORA example above, would be MyDbName. That is all there is to this step.

You can also create the ODBC data source programmatically. See the Microsoft knowledge base article on how this is done http://support.microsoft.com/support/, then search for article Q142216 which gives 2 non-Oracle examples. This is the only example I know of, but it should be sufficient as a starting point to trying this method for an Oracle data source. What has worked for me is the following.


lparameters lcODBCDriver, lcSettings
*
* For example:
*
* lcODBCDriver "Microsoft ODBC for Oracle"
* lcSettings "DSN=Locator"+chr(0);
*              +"Description=Region 6 Locator"+chr(0);
*              +"Server=OraServer"+chr(0);
*              +"UID=optional"
*
if parameters() <> 2
   return .f.
endif
if type("lcODBCDriver") <> "C" or empty(lcODBCDriver)
   return .f.
endif
if type("lcSettings") <> "C" or empty(lcSettings)
   return .f.
endif
if right(lcSettings, 1) <> chr(0)
   lcSettings = lcSettings + chr(0)
endif
#define  ODBC_ADD_DSN            1    && included so you know what
#define  ODBC_CONFIG_DSN         2    && can be passed as 2<SUP>nd</SUP> parameter
#define  ODBC_REMOVE_DSN         3
#define  ODBC_ADD_SYS_DSN        4
#define  ODBC_CONFIG_SYS_DSN     5
#define  ODBC_REMOVE_SYS_DSN     6
#define  ODBC_REMOVE_DEFAULT_DSN 7
DECLARE Integer SQLConfigDataSource in odbccp32 ;
   Integer, Integer, String, String
lnSuccess=SQLConfigDataSource(0,ODBC_ADD_DSN,lcODBCDriver,lcSettings)
return iif(lnSuccess > 0, .t., .f.)
<HR>

The third parameter in SQLConfigDataSource must be the exact driver name from the ODBC Administrator. In my case, we are using the MS 32-bit ODBC driver. The actual name you have to use for this driver is Microsoft ODBC for Oracle. Success is equal to 1 if successful, Zero if it fails. This function will automatically add 4 entries or more in the registry - the 3 listed above and the appropriate MS ODBC DLL file the ODBC driver uses. The number of entries depends on the number of parameters defined in the listings parameter. You should use the ODBC Administrator to create one yourself, then look in the registry to see what parameters were defined. Look in HKEY_CURRENT_USER\Software\ODBC\ODBC.INI of the registry.

At this point, you should now have a TCP/IP address for your workstation (this is left up to your Network Administrator to do), and have installed SQL*Net and the MS ODBC drivers. Your Oracle data source has been defined either manually through the ODBC Administrator or programmatically. You are now ready to launch VFP and start developing or upsizing your front-end application using an Oracle database.

Microsoft has an on-line Knowledge Base at http://support.microsoft.com/support/ which has much information on ODBC and Oracle. On this search page, I would select ODBC in Step 1, and type in Oracle in Step 5. The search engine will return all the pertinent articles. Good luck!

More articles from this author
Mark McCasland, September 1, 1999
Use the following to display the SQL progress bar without having the results [i.e., ### records selected in ### seconds] displayed on the screen or active window.
Mark McCasland, December 1, 2002
Authors: Tamar Granor, Ted Roche, Doug Hennig and Della Martin Publisher: Hentzenwerke ISBN: 1-930919-22-0 Retail Price: $69.95US for the printed book or $59.95US for the electronic [CHM] file only Publication Date: 2002 Pages: 372 printed, 4.1MB CHM file You also get the electronic ...
Mark McCasland, February 6, 2001
If you have a field that is used in multiple tables, you can get a list of all DBC member tables that the field occurs in by executing the following SQL command: select a.objectid, a.parentid, a.objectname fname, b.objectname tname, b.objectid tableid from MyDBC.DBC a join MyDBC.DBC b on a.parent...
Mark McCasland, December 9, 1999
Let's say you need to provide your users the Report Preview or Report Designer toolbars with your application. You need to provide your users with FOXUSER.dbf and .fpt. The only records you need to include in FoxUser are those whose ID = "TTOOLBAR". Assuming you have a folder where you place all ...
Mark McCasland, August 19, 1998
Using the following code to send a beep to the speaker[s]. External speakers and sound card are not required. It makes use of the MessageBeep Windows API function to accomplish it. It accepts a parameter to identify the beep type. Just pass the beep identifier to obtain a different type of beep.
Mark McCasland, April 11, 2003
This demo code will connect to Oracle [using your ID and password] to create a table of Presidents, a trigger, a sequence and some stored procedures. The stored procedures can be called to insert and update data in the Presidents table. Three of the methods in the VFP class will pass data values to...
Mark McCasland, June 4, 2001
One of the fastest ways to load bulk quantities of data into Oracle is to use the Oracle utility, SQL Loader. The purpose of this FAQ is to describe how to get your data into Oracle tables as fast as possible.
Mark McCasland, August 1, 2002
Authors: Harold Chattaway, Randy Pearson & Whil Hentzen Publisher: Hentzenwerke ISBN: 1-930919-07-7 Retail Price: $49.95 US, $74.95 CDN Publication Date: 2002 Pages: 492 Online information: Table of Contents, 8 appendices, Source Code and E-Book URL: http://www.hentzenwerke.com/ ...