On Mon, May 07, 2001 at 09:51:39AM +0530, [EMAIL PROTECTED] wrote:
> 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 strict;
use warnings;
> > 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;
Change DBI.errstr to $DBI::errstr.
> >
> > # my $rs= $dbh->prepare('Select * from Products where ProductId=?')or
> > # die " Sorry could not connect". $dbh.errstr;
$dbh->errstr;
> > for( $i=0;$i<$lt;$i++)
foreach my $k (@tryarr)
> >
> > {
> >
> > 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;
$dbh->errstr;
> >
> > # $rs->execute($tryarr[$i]);
> > $rs->execute();
Does this statement work?
> >
> > while(@data=$rs->fetchrow_array)
> > {
> > print"<br> Inside while \n";
> > $a=@data;
Don't use $a. $a and $b have special meaning that may bite you later.
See sort.
print map { "<li>$_\n" } @data;
> > }
> >
> > if($rs->rows==0)
> > {
> > print"No rows found $city" ;
> > }
> > else
> > {
> > print"job done";
> > }
> >
> > $rs->finish();
Only really needed if not selecting all the rows for the
statement.
> > }
> >
> > print "<br>End of if";
> >
> > print "</ul>\n";
> >
> >
> >
> > $dbh->disconnect();
--
Thomas A. Lowery
See DBI/FAQ http://tlowery.hypermart.net
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com