Tuesday, April 26, 2005

Compiling your own Perl - part 2: The Oracle Mod

Perl has a very useful generic database module called DBI. This mod does not, by itself, allow you to connect to any specific database. However, with the proper DBD module driver(DBD::) you can use the same code with different databases(providing the SQL you are using isn't in any way customized for that database). In the case of an open-source database (PostGreSQL, MySQL, SQLite, etc.) you can obtain everything you need to build the DBD module from the web. In the case of Oracle, you will have to have a purchase copy, an active Oracle database, and the client software loaded on your machine.

Mod's you will need:
DBI
DBD::Oracle

DBI is required before any DBD mods can be added. If you followed yesterday's instructions, and didn't have any problems with it, you should have a functional perl and a solid compilation environment to make modules. Here are the instructions for compiling DBI.
  1. Download DBI from CPAN and uncompress it in the same directory that the perl source code is in (C:\Dev\src\DBI-1.48 is mine for example).
  2. chdir into that directory.
  3. type: perl Makefile.PL
  4. type: dmake
  5. type: dmake test
  6. type: dmake install
  7. The above pattern is fairly standard for most perl mods. It's always a good idea to read the README and INSTALL files to make sure that some other step isn't required, but it is pretty unusual for anything else to be required. From this point on the above pattern will be referred to as the MAKE SEQUENCE.
  8. Assuming no error outputs, you should now have a functional DBI mod.
The next stage is to compile the DBD::Oracle mod. It requires a few things.
  1. An active oracle database.
  2. You must have a login to that db.
  3. You must install the Oracle client software, specifically you must install the C/C++ tools. In general you'll want to install anything that says 'C development' or header files. If I seem a little vague here, it's because I don't currently have to CD to see what components I installed.
  4. If all of these exists you can start the MAKE SEQUENCE. Perl Makefile.PL will give some warnings and make some noise, and dmake should execute cleanly. Then, you are ready to test.
  5. You need to type SET ORACLE_USERID=username/password@dbname on the command line. This will allow the tests to run. All tests should pass(some may be skipped). **WARNING** the extra tests run in test.pl will fail, due to the fact that it expects ORACLE_USERID to just equal username/password. So type SET ORACLE_USERID=username/password and then type the command perl test.pl dbname. You should look for the 'expected' results.
  6. Assuming you've gotten this far with clean compiles and tests, it's time to dmake install
  7. Finished.
Next installment: LWP and Crypt::SSLeay.

0 Comments:

Post a Comment

<< Home