
MDTech.us_MAN
Novice
Mar 1, 2013, 8:38 AM
Views: 3052
|
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:
#!/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)
|