
FishMonger
Veteran
Mar 1, 2013, 5:13 PM
Post #12 of 14
(320 views)
|
|
Re: [MDTech.us_MAN] Easiest way to run Microsoft SQL proc.
[In reply to]
|
Can't Post
|
|
I was going to recommend assigning '' an empty string to all undef fields, which is only 1 line of code, but it's just as easy to disable the uninitialized warning. However, you SHOULD NOT get into the habit of circumventing warnings just because you don't want to deal with it in a more appropriate manner. Take note that I broke up the statements in the while loop as well as the sql statement. The sql could be broken out a little more. Putting multiple statements on a single line is bad style and should be avoided.
my $sql = q/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';/; while(my @row = $sth->fetchrow_array) { no warnings 'uninitialized'; print join("\n", @row), "\n"; }
|