Hello,

Nick Gorham wrote:
> Be warned, you may get away with it, but you *can* put your server in a
> spin-lock doing this if you don't retrieve all the data from each row for each
> fetch.

Have you got an infinite loop when you don't retrieve all data?
Shouldn't you get an error message?

But following test code produce a lock:

$dbh->do("create table test2 (ns_name integer,ni_id integer)");
$dbh->do("create table test3 (ns_name integer,ni_id integer)");

$dbh->{AutoCommit} = undef;

#---- insert into table 1
for (my $i=0; $i < 10; $i++) {
  $dbh->do("insert into test2 (ns_name) values ($i)");
}

#---- insert into table 2
for (my $i=0; $i < 10; $i++) {
  $dbh->do("insert into test3 (ns_name) values ($i)");
}

#---- select first statement
my $sth = $dbh->prepare("
select ns_name from test2");
$sth->execute;

while ( my $rows = $sth->fetch) {
  print "Data from Table 1:",join(',',@$rows),"\n";
  #---- select second statement
  my $sth1 = $dbh->prepare("select ns_name from test3");
  $sth1->execute;

  while ( my $rows2 = $sth1->fetch) {
    print "\t",$rows2->[0],"\n";
  }
  $sth1->finish;
}
$sth->finish;

#--- drop tables
$dbh->do("drop table test2");
$dbh->do("drop table test3");

$dbh->disconnect;

if you delete the carriage return (or a tabulator) before "select" it
will work. other database/ database drivers ignore such characters.

Kind regards,

Stefan

Reply via email to