I am on TS 6.5 sp2 on windows. It is a know error that if we are doing fetchrow_array( ) inside our perl with MSSQL to get row data it fails. Is there a workaround for this. Here is my snippet.[html]my $getquery = "SELECT areavpath FROM tbl_products_generic WHERE areavpath='\products\servers'"; $sth = $dbh->prepare($getquery); $rc = $sth->execute; die($sth->errstr) if $sth->err; my $fetch=$sth->fetchrow_array( ); print "Fetch :$fetch\n";[/html]Fetch is always empty. Donno why.Thank You
...print "Fetch :" . join("\n", @{$fetch}) . "\n";
thank You adam for the reply. I got past the fetch part,So I am getting the array as it is supposed to, not that i have it, I am checking for a cetain occurance in that array and updating my table based on that, for some reason I am getting this error now and the update of the table is not happening.DBD:DBC::st execute failed: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt (SQL-HY000)(DBD: st_execute/SQLExecute err=-1)Here is my snippet[html] if ($new_location2 eq $data_table) { print "Am I here\n"; my $sel1 = $dbh->prepare("UPDATE tbl_products_generic SET content='Test123*' WHERE areavpath='$new_location2'"); $sel1->execute(); if ($sel1->errstr) { print "Oops There is an error"; } } [/html]p.s. $new_location2="\\"."products"."\\"."servers";Thank You
I am stumbling at a simple while loop and I could never get my if loop to run even though the condition is met. can you correct me please[html] while ( ($new_location) = $sth->fetchrow_array( ) ) { $new_location2 .=$new_location; print LOG "Location : $new_location2\n"; } if ($new_location2 eq $data_table) { print LOG "Am I here\n"; }[/html]Thank you
Your code again seems to be assuming that fetchrow_array is returning a string instead of an array - which you are stuffing into a scalar instead of an array (if you want the scalar ref, you need to use fetchrow_arrayref) - and in either case you cannot use the .= operator when dealing with arrays or references to arrays.
Try this.[html] .... ... my $flag = "0"; foreach $_(@make) { my $new_location3=$_; print "$_\n"; print "||$new_location3||$data_table||\n"; if (($new_location3) eq ($data_table)) { $flag = "1"; print "Variables are Equal:$flag\n"; } else { print "Variables are Not Equal"; } } if ($flag eq "1") { print "Variables are Equal\n"; //This executes either once or not } else { print "Variables are Not Equal"; //This executes either once or not }[/html]
Thank You Adam, I Totally agree with you. And in this regard I have changed my code so that I can get the array. When the array is being read inside the forloop. But at some point when the variable is read in forloop I am expecting the if statement to be executed but what exactly is happening is the else part is executed fine and the if part always fails, I other words for any value of $data_table, the if loop is stuck in the else part.Here is the snippet.Thanks[html] while ( ($new_location) = $sth->fetchrow_array( ) ) { $new_location2 =$new_location; push(@make, $new_location2); } foreach $_(@make) { my $new_location3=$_; print "$_\n"; } if (($new_location3)eq($data_table)) { print "Variables are Equal\n"; } else { print "Variables are Not Equal"; }[/html]
while ( ($new_location) = $sth->fetchrow_array( ) ) { $new_location2 =$new_location; push(@make, $new_location2); }
while ($new_location = $sth->fetchrow_arrayref()) { push(@make, $new_location); # unclear if this is really what you want, but ...}
while (new_location = $sth->fetchrow_array()) { push(@make, new_location);}
foreach $_(@make) { my $new_location3=$_; print "$_\n"; }
my $new_location3 = $make[-1];
if (($new_location3)eq($data_table)) { print "Variables are Equal\n"; } else { print "Variables are Not Equal"; }