SQL Server
  Home arrow SQL Server arrow Page 4 - Executing SQL Server Stored Procedure from...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
SQL SERVER

Executing SQL Server Stored Procedure from Perl
By: Jack Zhang
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 71
    2004-06-01

    Table of Contents:
  • Executing SQL Server Stored Procedure from Perl
  • History Lesson: SQL Server(s)
  • TDS protocol
  • Setup Perl and SQL Server on Windows
  • Create A Stored Procedure on Sybase Adaptive Server

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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:

    Executing SQL Server Srored Procedure from Perl

    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:

    SQL Server & Perl

    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.

    More SQL Server Articles
    More By Jack Zhang


     

    SQL SERVER ARTICLES

    - Executing SQL Server Stored Procedure from P...
    - How to Search for Date and Time Values Using...
    - Replication: SQL Server 2000 - Part 2
    - Replication: SQL Server 2000 - Part 1
    - SQL Sever: Storing Code in Binary or Text Fi...
    - Execute SQL on Multiple Tables/Columns - New...
    - How to Connect to a SQL Server from Visual F...
    - SQL Server Hardware Tuning and Performance M...
    - Primary Key on Multiple Tables – New RDBMS C...
    - Migrating from Sybase to SQL Server
    - What's Best for DBAs? GUI or T-SQL Comma...
    - How to Perform a SQL Server Performance Audit
    - An Introduction To The Bulk Copy Utility
    - SQL Server Stored Procedures 101
    - Building Your First SQL Server 2000 Database






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT