Executing SQL Server Stored Procedure from Perl - Setup Perl and SQL Server on Windows
(Page 4 of 5 )
Perl’s running environment is integrated within the *nix system. For Microsoft Windows operating systems, however, you need to download and install it by yourself.
There are a few Windows-based distributions of Perl. ActivePerl from ActiveState.com may be the most popular one. You can download it from:
http://www.activestate.com/Products/ActivePerl/
Choose the latest version of ActivePerl (5.8) (most recent Unix/Linux also uses Perl 5.8).
Installing ActivePerl on Windows is fairly easy. After installation you can use the following command to verify that perl is working:
From command prompt, input:
Perl –v
It will show you something like:
This is perl, v5.8.0 built for MSWin32-x86-multi-thread
Copyright 1987-2002, Larry Wall
Download Sybase Adaptive Server 12.5 Developer Edition from the Sybase website for free: www.sybase.com/ase_125devel
Installing and configuring Sybase Adaptive Server is also as easy as MS SQL Server.
If you want to use MS SQL Server as a database, install MS SQL Server 7.0 with service pack 2.
Perl uses DBI/DBD architecture to access databases (DBI means Database Interface, DBD means Database Driver). With a specific DBD driver installed, Perl can use the same DBI API to support different database systems.
The DBI module is already installed with the ActivePerl distribution itself. In order to support SQL Server, we need to download the SQL Server DBD driver from cpan.org: www.cpan.org, search for the DBD-Sybase module, and download the latest version 1.01 source code: DBD-Sybase-1.01.tar.gz
Note: there are a few other DBD Drivers that support both Sybase and Microsoft SQL Server on Windows, such as DBD::ADO; however, they can only be used on a Windows platform.
In order to compile and install the DBD::Sybase source code, we need a C compiler installed on Windows (I use Microsoft Visual C++ 6.0), and make sure nmake.exe is available in the PATH.
Use a decompression utility (ie: Winzip) to extract DBD-Sybase-1.0.1.tar.gz to any available drive such as C:. You should now have the folder c:DBD-Sybase-1.01 that holds all the source code.
Change directory to the above folder, and issue the following command in the command prompt window:
Perl Makefile.PL
You may receive a warning message, such as missing the following library: libtcl.lib, libcomn.lib and libintl.lib.
Because we are using the Sybase CT-Library, libcs.lib and libct.lib are mandatory; others are optional, and we can ignore this warning. Sybase removes these static libraries from its version 12.5 of the Adaptive Server package. The run time libraries still do exist (ie: libtcl.dll, libcomn.dll, linintl.dll) See the following screenshot:

If you receive an error message other than the one above, please check the following environment variable: SYBASE and SYBASE_OCS
%SYBASE% should equal the directory root where Sybase Adaptive Server is installed (ie: C:sybase) and %SYBASE_OCS% should equal OCS-12_5 for Sybase Adaptive Server 12.5
Issue the following command to compile the source code:
Nmake
Then install the package by issuing this command:
Nmake install
Using the following code, we can list all the DBD drivers we’ve installed with Perl:
#!/usr/bin/perl
use strict;
use DBI;
my @drivers=DBI->available_drivers();
print join("n",@drivers);
print "n";
Copy and paste the above code in notepad, and save the file as dbi_drivers.pl.
Issue the following command in the command prompt window:
perl dbi_drivers.pl
See following screenshot:

I recommend you download PerlIDE from open-perl-ide.sourceforge.net, it is a free and open source tool. You can download the precompiled application and install it easily on your Windows operating system. With PerlIDE, you can debug and track variables in your Perl applications.
Next: Create A Stored Procedure on Sybase Adaptive Server >>
More SQL Server Articles
More By Jack Zhang