Many thanks to all of you who sent me advice. Everything's working OK now It turned out that there wasn't any data in one of the tables in my SELECT as this is a new DB with a few unpopulated tables yet.
Thanks again,
Tom Castonzo On Friday, June 6, 2003, at 08:12 AM, JT MacNeil wrote:
Good Morning,
Two things. First, are you sure there is data there to begin with? Check
with a command-line interface or dbish.
Second, try using a different statement handle for the other query. Or,
just do a JOIN between the two tables (rental_units & weekly_rental_rates)
and grab everything from that.
HTH, J-T MacNeil Design Team Member, Connect 24 Division Digital Security Controls Phone: (905) 760-3000 x7302 e-Mail: [EMAIL PROTECTED]
-----Original Message----- From: Thomas Castonzo [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2003 6:15 PM To: [EMAIL PROTECTED] Subject: Executing multiple statements in one application Importance: Low
Hello All,
I'm trying to do a SELECT, process some data from the SELECT and then a little later, an INSERT OR SELECT in the same application. This is how I'm trying to do it but I'm not getting any output for the 2nd SELECT statement
TIA,
Tom Castonzo
#<snippet> $dbh = webConnectDB::connect();
#The SQL query $sth = $dbh->prepare(" SELECT house_number,low_rate,mid_rate,high_rate FROM weekly_rental_rates WHERE house_number = ? ");
#Convert the param into an SQL-friendly format $sth->bind_param(1,$rental); #coming in from a form
$sth->execute();
############################################################ #Associate perl variables with each output column # These variables come from the SELECT statement in this case $sth->bind_columns(\$c1, \$c2, \$c3,\$c4); ############################################################
print"<table align=\"center\" width=\"600\" border=\"1\" bordercolor=\"black\"><tr bgcolor=\"#3399cc\"><th>House Id</th><th>Low</th><th>Mid</th><th>High</th></tr>\n"; while( $sth->fetch) { print"<tr align=\"center\" bgcolor=\"#ffffff\"><td>$c1</td><td>$c2</td><td>$c3</td><td>$c 4</td></tr>\n" ; }
print"</table>\n";
#Try to reuse our statement handle $sth my ($c5); $sth = $dbh->prepare("SELECT house_name FROM rental_units WHERE house_num = ?
"); $sth->bind_param(1,$rental); $sth->execute(); $sth->bind_columns(\$c5);
# Nothing is outputting here while($sth->fetch) { print"Rental Unit Data: $c5<br>\n"; }
#</snippet>
