Tom,

You should include RaiseError=>1 in your connect and you might get more
information about the problem.

Two things that I notice about your code:

I always put the call to  "bind_columns()" before the execute.

I always put an "undef" as the first paramater to bind_columns(). It may not
be necessary on newer versions of DBI, but it is in older versions.

Try making those changes, it might do the trick.

If you don't already own it, consider buying "Programming the Perl DBI" from
O'Reilly press.

Tim

-----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


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>$c4</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>

Reply via email to