16 September 2001 Douglas Clark is a program management consultant who first started using OS/2 version 1.3. He's married, with 2 girls, and is old enough to remember when 4 color mainframe terminals were a big thing. If you have a comment about the content of this article, please feel free to vent in the OS/2 eZine discussion forums. There is also a Printer Friendly version of this page. |
|
ODBC on OS/2 Part 5
This month we continue looking at ODBC enabled databases, or clients. We cover how to connect to Microsoft's SQL Server (client only), and we look at PostgreSQL which is a very impressive open source database which has been ported to OS/2. Sorta like a look at the evil empire and the empire strikes back type story.
| ||||||||||||||||||||||||||||||||||||||||||
MS SQL ServerMicrosoft SQL Server is a database server that only runs on Windows operating systems. The server has appeared as version 6, 6.5, 7, and now is called SQL Server 2000. Microsoft supplies clients for various Windows platforms but does not supply a client for OS/2 (big surprise!). However Microsoft SQL Server is very closely related to Sybase server, which was covered in Part 4. This close relationship between Sybase and Microsoft SQL Server allows us to connect to Microsoft SQL Server from OS/2 using the Sybase client. On the OS/2 side we use the Intersolv v 2.11 Microsoft SQL Server ODBC driver and the Sybase System 10 client package. In WinOS2 we use the Microsoft SQL Server client for Windows 3.1 and the Microsoft ODBC driver. While both of these solutions are geared towards version 6/6.5 of Microsoft SQL Server they should also connect to version 7 and 2000. According to Microsoft the version 6 client of Microsoft SQL Server can connect to all existing versions of Microsoft SQL Server with the usual caveat that advanced features of later versions may not work on older version clients. But since ODBC shields us from most of that "advanced" feature stuff, and since almost all the SQL processing happens on the server anyway, OS/2 ODBC applications should work just fine with Microsoft SQL Server no matter what the version. The procedures I describe below have been tested with Microsoft SQL Server v 6.5 running on Windows NT version 4.0.Installing Microsoft SQL Server on OS/2To connect OS/2 ODBC applications to Microsoft SQL Server we must use the Intersolv version 2.11 ODBC driver for Microsoft SQL Server since Intersolv never released this driver as version 3.01. The Intersolv driver uses the Sybase client to communication with Microsoft SQL Server - the same Sybase client that we installed in Part 4 - last month's article. So rather than repeat those installation instructions, which were rather long and involved, I will only list the differences or additions needed for Microsoft SQL Server and direct you to last month's article for the rest of the steps. The differences are:
Note: you can use the Sybase client to connect to Sybase servers and Microsoft SQL Servers at the same time. If you have already setup the Sybase client for a Sybase server, adding the Microsoft SQL Server "service" will not affect the Sybase settings or connections.
The screen shot below shows the Database Designer that is included as part of VisPro C/C++, VisPro Reports, and I think VisPro Rexx. The database shown is the pubs example database that is normally installed as part of Microsoft SQL Server 6.5. The Database Designer is an application that diagrams an existing database (something VisPro calls "reverse engineering"), and allows you to create new tables and relationships. Each box represents a table in the database. The lines between the boxes/tables depict the relationships between the tables established by primary and foreign keys.
Installing Microsoft SQL Server on WinOS2The Microsoft client for Windows 3.1 includes an ODBC driver. The client can be found any distribution of Microsoft SQL Server. The example I am showing below is from v 6.5.
You can now use ODBC for Microsoft SQL Server data sources in WinOS2. ConclusionWhile Microsoft SQL Server does not interest us as a database server since it doesn't run on OS/2, it does interest us because of its increasing popularity. And we often do not get to choose what databases other people or departments use, especially the ones that contain data we really need to get at. My ability to use OS/2 in the corporate world depends on OS/2's ability to integrate well enough into the existing, sometimes hostile, corporate computing environment so that I can get my job done. This driver and the ability to connect to Microsoft SQL Server helps OS/2 fit in.PostgreSQL 7.1PostgreSQL is an object-relational database management system (ORDBMS) based on a system called POSTGRES, developed at the University of California at Berkeley. PostgreSQL is an open source descendant of this original Berkeley code. It provides SQL92/SQL99 language support and other features such as triggers and constraints. The object part is implemented as table inheritance/hierarchy, array data types and user defined functions - similar to how "objectness" is implemented in Oracle and DB2. PostgreSQL is implemented on Linux and various Unix systems, Windows and on OS/2; the OS/2 port by Venuto Monrif is an excellent port; however I ran into some installation issues - see All OS/2 Versions install section below. The latest version, 7.1 which came out a couple of months ago, is a major upgrade from version 7.02. It adds major new SQL features, upgraded documentation, and a new GUI administrator tool, which is a work in process. If you looked at version 7.02 and were disappointed with the SQL capabilities you ought to look at this version; in terms of SQL language features this version is up there with DB2/2 or Oracle.PostgreSQL has an extremely rich set of data types, which include the usual date, character, and numeric types as well as PostgreSQL specific types like box, circle, line, path, lseg (line segment in 2D plane), point and polygon, inet (IP Address), money, and time with and without a time zone. All data types can also be single or multi-dimension arrays - which violates one of the tenets of the relational model but is becoming common in object/relational databases - see last months article. The implementation of SQL is very complete, with features like:
PostgreSQL has its own procedural language called PL/pgSQL which is roughly modeled after Oracle's PL/SQL. It can be used in creating procedures/functions and triggers. According to the documentation PostgreSQL also supports 2 other procedural languages in those roles: PL/Tcl and PL/Perl - although I have not tested this and do not know if PL/Tcl or PL/Perl are supported on the OS/2 port. You can also program functions and modifications to SQL in C. PostgreSQL is a very customizable database. An example of this is something PostgreSQL calls "rules". Rules are sort of like a decision tree on what PostgreSQL should do as it processes SQL and other statements. You can "hook" into those rules and modify PostgreSQL behavior in special circumstances. This is somewhat like Oracle's "instead of" triggers that allow you to substitute a different SQL statement or procedure for the one that tripped the trigger. Where I have found the most use for this type of feature is in making views that would normally not be updatable. Most databases will not handle updates to views that are very complex, and sometimes complex is considered to be nothing more than two tables joined in a single view. "Instead of" processing can be used to make those types of views updatable, because while the database doesn't know how to update the view, you do. So you write an "instead of" procedure/trigger that is tripped by the update view statement which substitutes update statements for each of the constituent tables for the statement that triggered the procedure. One of the nasty little side effects of normalizing database tables (the process of breaking data into separate tables with on duplication of data and with clear relationships) is that the data structure often assumes forms that are alien or cumbersome to the end user. If it not unusual to spend enormous amounts of time on the front end applications making the data look more "real world like" and yet still allow the data to be updatable. "Instead of" features can save lots of time spent on front end applications.
There are also a number of other features, or "modules" as they are called in the distribution, for specialized processing. These are not part of the "official" package but are included anyway. Included are array iterator functions, a multi-dimensional cube data type, an operator for computing earth distance for two points, full text indexing using triggers, data type extensions for ISBN/ISSN (books/serials) numbers, large object maintenance, trigger to prevent updates on a single column, and cryptographic hash functions. Installing PostgreSQLI installed, or tried to install, PostgreSQL on three machines: Warp v 4, WSeB, and an eComStation look-alike (WSeB with the networking replaced by Warp v4 networking, and TCP/IP upgraded with TCP/IP 4.2 - hey, I built it before eComStation came out). The install on the eComStation look-alike worked well (with a modified file as explained below). The install on Warp v 4 would run the server - but I couldn't get the ODBC driver or the GUI Administrator application to connect to the server on the same or another machine. Plus Warp v 4 requires 32bit TCP/IP, which is described below. The install on the WSeB machine would not initialize the database - hence the server could not be used, but it worked fine as a client. I'll cover the additional steps needed for Warp v4; if you are running that version you will have to follow those steps in addition to the ones for All OS/2 Versions that follow. Later versions can jump to the All OS/2 Versions section. Warp v 4 The PostgreSQL ODBC driver and the server both require the 32 bit implementation of TCP/IP, which is not part of version 4 - version 4 has an older 16 bit TCP/IP implementation. When I installed the server on Warp 4 I could initialize the template database but could not create a new database; I got an error in a PostgreSQL DLL file. After installing TCP/IP v 4.1 I could create a new database and connect to PostgreSQL servers, but I could not issue any SQL statements via ODBC without getting an "invalid packet length" message. Also the GUI Administrator would not connect to any database. But the console applications worked fine against the local databases. This problem may be related to my upgrade of TCP/IP on that machine, which ended up being very problematic - I never did get the upgrade completely finished so that the machine would boot without an error message. I was able to communicate just fine, both ODBC and the GUI Administrator, from my WSeB machine (which runs TCP/IP v 4.2) to my modified WSeB machine which runs TCP/IP v 4.1 Versions 4.1, 4.2 and 4.3 are all 32 bit implementations of TCP/IP. I know you can use v 4.1 to upgrade Warp 4 and assume, but do not know for sure, that you can also use the other two version to upgrade Warp 4; I know you can use v 4.1 to upgrade. But in order to install and run any 4.x version you must also have at least Java 1.1.1 installed and running; and both packages require something called "Feature Install". Feature Install and TCP/IP 4.3 are available from Software Choice - click on Software Catalog; Feature Install is free, the TCIP/IP 4.3 package requires a subscription to Software Choice. TCP/IP was also available on the Developer's Connection CD pack from December 1999 on. The Java Runtime used to be free, but I can no longer locate it on IBM's web site. Since installing and upgrading TCP can be complex, I will not give step by step instructions, but rather hints from many bloody hours of installing this stuff.
If you only want the install the client skip to the section on the ODBC driver. The following steps will initialize a template database, and then create our database to work with.
The Administration GUI tool is still a work in process. Some of the options work and some have yet to be implemented. It will be nice when it is completed. The file x:\pgsqldata\pg_hba.conf contains authentication information used to validate database connections. You edit the file and add lines for each IP address or domain that you want to allow connections from, along with the type authentication required. Now we are ready to install the ODBC driver. ODBC PostgreSQL only has an OS/2 ODBC driver; there is not a WinOS2 (Win16) ODBC driver. This is unfortunate because there are some very nice Windows 3.1 applications that run well on WinOS2 and are very useful for database work. Installing the ODBC driver is very easy. If you use the ODBC Installer ODBCINST3.ZIP then you will not have to modify the CONFIG.SYS. There is also an installation program included in the PostgreSQL ODBC driver package, but you will have to modify your CONFIG.SYS file afterward to correct the ODBC_PATH and LIBPATH statements if you use this program.
The PostgreSQL ODBC driver does not work correctly with Lotus Approach or StarOffice. Lotus Approach is apparently calling an ODBC function that is not implemented in the driver. It's hard telling what StarOffice is doing since there are some other databases/drivers it doesn't work with. I was not able to test VX-Rexx against this version of the driver because VX-Rexx does not run on my WSeB/modified WSeB machines and I had the invalid packet length error on the Warp v4 machine; I have heard reports that the previous version of the driver did not work with VX-Rexx.
ConclusionAmong the so called "open source" SQL databases available on OS/2 - PostgreSQL, mySQL, miniSQL - PostgreSQL is feature-wise vastly superior in every way. PostgreSQL also compares very favorably with commercial databases, at least in the feature and design areas. The icing on the cake is the price. PostgreSQL is free, both for personal and for commercial use. It is the most free of all the open-source databases. The down side is that the implementation is rather weak. ODBC functions are missing or incorrectly implemented in the ODBC driver; Lotus Approach and StarOffice will not work correctly with the driver. Large Object implementation is weak in the ODBC driver. Installation is difficult or impossible on some systems, or at least my machines. And the documentation is missing some sections. Despite the implementation weaknesses this is really an outstanding database. When I looked at the previous version I wasn't too impressed, but this version has won me over. The good news is that with this version the database is pretty much complete feature-wise. This means that future development will probably concentrate on the implementation weaknesses and enhancing performance. Stuff DescribedThe VisPro Database Designer is an application that is bundled in the VisPro C/C++, VisPro Rexx, and VisPro Reports products. The VisPro product line is made by the Hockware Company. Or I should say was made by Hockware, since it appears that Hockware has gone out of business. You can still occasionally find VisPro products on eBay. Which is a shame because while the support was less than pleasant, the products were generally very good. If you work with databases much the Database Designer is a valuable product. You can use it to view the existing relationships between tables in a database, or to create tables and establish key relationships between tables. Sybil is an application development environment based on Object Pascal. It is designed to be an OS/2 equivalent to Borland's Delphi v 1. OS/2 eZine has reviewed Sybil in the past, and we will discuss it again in relation to ODBC application development in a few months. Sybil has been dismissed because the compiler is slow (which is true), and because parts of it are buggy, which is also true, especially with ODBC. However you can still develop applications very quickly with it, and you can develop complex applications. Newview is an example of an excellent application that was developed with Sybil. Included in Sybil is a small application called Database Designer. This shows the database structure for ODBC databases: tables, indexes, etc.Lotus Approach has also been recently reviewed in OS/2 eZine. It is a database application which is built on the dBase file format. The screens can also be used on any ODBC data source, or any ODCB data source that works with Approach. Lotus Approach is bundled with eComStation as part of SmartSuite, which among other reasons makes eComStation an outstanding value.
Next month we will cover DB2/2 along with a very interesting product called Visualizer Query
which integrates database applications into the workplace shell,
Sybase SQL Anywhere, and possibly mySQL and miniSQL which will finish up the ODBC databases. After that we start on programing in ODBC.
|
||||||||||||||||||||||||||||||||||||||||||||
|