CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [FishMonger] Easiest way to run Microsoft SQL proc.: Edit Log



MDTech.us_MAN
Novice

Mar 1, 2013, 8:38 AM


Views: 715
Re: [FishMonger] Easiest way to run Microsoft SQL proc.

It's saying the value is uninitialized because the SQL proc returned NULL. (This it what I want)

Here is the code:

Code
#!/usr/bin/perl 
use strict;
#use warnings;
use DBI;
use CGI;
use DBD::ODBC;

my $cgi = CGI->new;

print "Content-type: text/html\n\n";

print "<html><head><title>TST</title></head><body>";

use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

#print $DBD::ODBC::VERSION;

my $db_instance = "192.168.1.6\\MDTSQL1";
my $db_name = "BCPADB";
my $db_user = "Maxwell175";
my $db_pass = "mD1234567890";
my $dbh = DBI->connect("dbi:ODBC:Driver={SQL Server};Server=$db_instance;UID=$db_user;PWD=$db_pass");
my @rows = ();
my $sql = "USE [BCPADB]; DECLARE \@return_value int, \@Exists bit, \@OutErrMsg varchar(100); EXEC \@return_value = [dbo].[Check_if_Rec_Exists] \@Email = N'admin\@mdtech.us', \@Exists = \@Exists OUTPUT, \@OutErrMsg = \@OutErrMsg OUTPUT; SELECT \@Exists as N'\@Exists', \@OutErrMsg as N'\@OutErrMsg', \@return_value as N'Return Value';";
my $sth = $dbh->prepare($sql) or die("\n\nPREPARE ERROR:\n\n$DBI::errstr");
$sth->execute or die("\n\nQUERY ERROR:\n\n$DBI::errstr");
while(@rows = $sth->fetchrow_array()) { print join("\n", @rows); print "\n"; } # <-- Here is where I use @rows.
$dbh->disconnect;


print "</body></html>";



(This post was edited by MDTech.us_MAN on Mar 1, 2013, 10:16 AM)


Edit Log:
Post edited by MDTech.us_MAN (Novice) on Mar 1, 2013, 10:16 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives