Hi DBI users I am very new to Perl ( in fact only 15 days)
>
> I dont know about type of discussion but I need a Urgent help
>
> I was trying to retrieve from my SQL server 7.0 database values .I am
> giving values to the Query condition through a
>  array but After executing only first it aborts not taking other values.
>
> Code is it is only fetching values for Product Id=3456 and then
terminates
> the loop.
>
> #!c:/perl/bin/perl
> use CGI qw(:standard);
> use DBI;
> $ query= new CGI();
>
> @tryarr=(3456,3457,3489,2723);
> $lt=@tryarr;
>
>   my $dbh= DBI->connect('DBI:ODBC:SCART','team','team') or
>   die " Sorry could not  connect". DBI.errstr;
>
>  # my $rs= $dbh->prepare('Select * from Products where ProductId=?')or
>  # die " Sorry could not  connect". $dbh.errstr;
>
> print $query->header();
>
> print start_html();
>
> #  table started
>
> print"<center>";
> print"<table >";
>
> for( $i=0;$i<$lt;$i++)
>
>         {
>
>                print "<br>Inside there is if and loop\n";
>
>
>                   $k=$tryarr[$i];
>
>                   print "<br>$k";
>
>            $rs= $dbh->prepare("Select * from Products where ProductId
> =$tryarr[$i]")or
>                    die " Sorry could not  prepare". $dbh.errstr;
>
>             # $rs->execute($tryarr[$i]);
>                 $rs->execute();
>
>          while(@data=$rs->fetchrow_array)
>                {
>                      print"<br>  Inside while \n";
>                      $a=@data;
>               for ($i=0;$i<$a;$i++)
>                     {
>                      my $Name=$data[$i];
>
>                      print "<li>$Name\n";
>
>                     }
>                 }
>
>             if($rs->rows==0)
>                 {
>                   print"No rows found $city"   ;
>                 }
>             else
>              {
>                    print"job done";
>                       $rs->finish();
>              }
>
>          }
>
>           print "<br>End of if";
>
>           print "</ul>\n";
>
>
>
> $dbh->disconnect();
>
> Regards to all
>
> Anurudh

Reply via email to