#!/home/y/bin/perl use DBI; use File::Basename; #Database handler my $dbh= DBI->connect("dbi:mysql:$conf{MSQL_DB}:$conf{MSQL_DB_HOST}:33 +06", "$conf{MSQL_DB_USER}" , "$conf{MSQL_DB_PSW}" , { RaiseError => 1 +, AutoCommit =>0} ) || die "Database Connection Failed: $DBI::errstr" + ; print "$conf{MSQL_DB} DB :Connection succeeded\n"; my $pr = qq{select emp_id, first_name from employee where city= "Atlan +ta" }; #stage prepare and execute my $sth = $dbh->prepare($pr); $sth->execute(); # bind sql columns $sth->bind_columns( undef, \$emp_id, \$first_name); while ($sth->fetch) { print "EMP_ID = $emp_id, FirstName=$first_name \n"; # Capture the quarantine_stage_id my $pr1 = qq{select customer_name from customer where id = $emp_id } +; # Prepare and Execute the SQL statement my $sth1 = $dbh->prepare($pr1); $sth1->execute(); $cust_id; $sth1->bind_columns( undef, \$cust_id ); while ($sth1->fetch) { print "Customer Table: Customer ID = $cust_id \n"; if ($emp_id == $cust_id) { print "\n Match\n"; } else {print "Doesn't Match"} } $sth1->finish(); } $sth->finish(); $dbh->disconnect();
In reply to how to use nested statement handler? by hardikv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |