$! in error checking for DBI? my version
#!/usr/bin/perl --
use strict; use warnings;
use DBI;
use DBD::SQLite;
Main( @ARGV );
exit( 0 );
sub Main {
my $tmpfile = 'sqlite-deleteme.tmp';
my $dbh = DBI->connect(
"DBI:SQLite:database=$tmpfile",
undef, undef,
{qw/RaiseError 1/}
);
$dbh->do('CREATE TABLE test (id integer PRIMARY KEY, foo varchar(1
+00))');
roshambo( $dbh, 1, 1 => "ro" );
roshambo( $dbh, 2, 2 => "sham" );
roshambo( $dbh, 3, 3 => "bo" );
roshambo( $dbh, 999, 999 => "999" );
undef $dbh;
unlink $tmpfile;
}
sub roshambo {
warn "\n### @_\n";
my( $dbh, $trace, $id, $foo ) = @_;
$dbh->trace( $trace );
my $sth_ins = $dbh->prepare('INSERT INTO test (id, foo) values (?
+, ?)');
$sth_ins->execute( $id, $foo );
$sth_ins->finish;
undef $sth_ins;
$dbh->trace(0);
warn "### @_\n\n";
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.