Folks

#!/usr/bin/perl
use strict;
use warnings;
use DBI;
# -----------------
my($dbh) = DBI -> connect
(
        'dbi:mysql:test', 'user', 'pass',
        {
                AutoCommit                      => 1,
                PrintError                      => 0,
                RaiseError                      => 1,
                ShowErrorStatement      => 1,
        }
);
my($table_name) = 't';
my($sql)                = "drop table if exists $table_name";
print "SQL: $sql. \n";
$dbh -> do($sql);
$sql = "create table $table_name (t_id int)";
print "SQL: $sql. \n";
$dbh -> do($sql);
$sql = "insert into $table_name (t_id) values (?)";
print "SQL: $sql. \n";
my($sth) = $dbh -> prepare($sql);
$sth -> execute(99);
$sth -> finish();
$sql = "drop table if exists $table_name";
print "SQL: $sql. \n";
$dbh -> do($sql);
# Warning: The following SQL is invalid.
# It should be "create table $table_name (t_id int)".
$sql = "create $table_name (t_id int)";
print "SQL: $sql. \n";
# The following fails, but displays the SQL
# "insert into $table_name (t_id) values (?)".
# The DBI docs explicitly state (allege!) that
# ShowErrorStatement applies to do().
$dbh -> do($sql);
--
Cheers
Ron Savage, [EMAIL PROTECTED] on 07/01/2003
http://savage.net.au/index.html


Reply via email to