Quoting xaver biton <[EMAIL PROTECTED]>:
>> Perhaps if you list what you want to happen and what is happening in
>> more detail we can help.
One thing I forgot to mention before, I don't see any error checking. Do you
have $dbh->{RaiseError} set? If you don't, you need to check for errors at
each method call or you don't get any clues about what error occured.
See http://search.cpan.org/~timb/DBI/DBI.pm and search for RaiseError and errstr
for examples of both.
> my $sql = $dbh->prepare(q{select col1, col2, col3 from test});
>
> the second:
>
> my $sql1 = $dbh->prepare(q{select row1, row2, row3 from test1 where
> test1.row = ?})
>
> $sql->execute();
>
> while(my @col = $sql->fetchrow_array){
> $sql1->execute($col[3]);
> while(my @row1 = $sql1->fetchrow_array){
> print "$row1[1]\n";
> }
> }
>
> by querying the table if $col[3] doesn't match I want to save $col[3] in
> a variable so that late can insert this in an extra table.
> something like: $notmatch = $sql1->fetchrow_array();
> if ($notmatch != col[3]){print $col[3];}
I think that was the second possibility I mentioned. If the inner query doesn't
find any rows, you want to do something else.
$sql->execute()
or die "Outer execute failed: $DBI::errstr\n";
while( my @col = $sql->fetchrow_array ) {
$sql1->execute($col[3])
or die "Inner execute failed for '$col[3]': $DBI::errstr\n";
my $counter = 0;
while( my @row1 = $sql1->fetchrow_array ) {
print "Match for '$col[3]': '$row1[1]'\n";
++$counter;
}
die "Inner fetch failed for '$col[3]': $DBI::errstr\n"
if $DBI::err;
if ( ! $counter ) {
print "No Match for '$col[3]'\n";
# Save in variable or insert into table.
}
}
die "Outer fetch failed: $DBI::errstr\n" if $DBI::err;
--
Mac :})