Perl 5.8.8 on Redhat 5.5.56

I decided to try DBD::SQLite and am getting no where fast. I create a new table, insert a record, then I cannot find the record again via SELECT. I don't get an error, I just get 0 records returned. (Actually, the object returns '0E0', which means zero records returned anyway.) Here's my code opening the db and creating the table.

use DBD::SQLite; my %attr; $attr{AutoCommit}=1; # Turn on AutoCommit. if (! -e $dbfile) { $dbh=DBI->connect("dbi:SQLite:$dbfile", undef, undef, \%attr) or die "Could not open $dbfile: $DBI::errstr"; # Now create table. $sql="CREATE TABLE data "; $sql.="(skey TEXT PRIMARY KEY, "; # Was varchar(30) $sql.="svalue TEXT)"; $sql.=";"; $ret=prepex($sql); } else { $dbh=DBI->connect("dbi:SQLite:$dbfile", undef, undef, undef) or die "Could not open $dbfile: $DBI::errstr"; } $s="SQLite version: ".$dbh->{sqlite_version}; writeerr($s); SQLite version: 3.8.4.1
Then I execute these statements in order. Every SQL statement is executed with the routine prepex().
###################################################################### +##### # Prepare then execute SQL statement. # In: SQL statement # Out: change global var $sth. Return rows affected. # See $DBI::rows: rows returned? # $DBI::errstr: error string sub prepex {my($sql)=@_; my(@a,@b,$i,$j,$procname,$s,$t); my($key,$data,$ret,$rows); $procname="prepex()"; $rows=0; $s="$procname: Runnning sql: $sql"; writeerr($s); eval { $sth=$dbh->prepare($sql); }; if ($@) { $s="$procname: ERROR on prepare: $@"; writeerr($s); } eval { $sth->execute(); $rows=$DBI::rows; # Also $sth->rows; #$ret=$ret+0; # Remove '0E0' code. #$dbh->commit or die $dbh->errstr; # Do not use with AutoCommit. }; if (($@) or ($DBI::errstr)) { $s="$procname: ERROR on execute: $@"; writeerr($s); } #$s="$procname: Rows returned: $DBI::rows"; #writeerr($s); if (len($DBI::errstr)>0) { $s="$procname ERROR from DBI: $DBI::errstr"; writeerr($s); } return $rows; # prepex } Then I execute these SQL statements. CREATE TABLE data (skey TEXT PRIMARY KEY, svalue TEXT); INSERT INTO data (skey, svalue) VALUES ('Stuff', 'Ge 1:1-more &stuff& +here '); SELECT svalue FROM data WHERE skey='Stuff'; # This one fails with 0 re +cs returned
The final SELECT fails with no records found. Am I missing something about oddball characters in a string field? Is there something else going on I'm not seeing? I have no experience with SQL. I've been going over this for about 3 hours trying different things, to no avail.

Thank you.

EDIT. We are using ampersands in the SQL statement data (and other odd characters) to indicate formatting like bold and italic. They will later be put into a text file, then put into Word, and formatted appropriately. We might also us caret (^), pound (#), dollar sign ($), or others.

Perl 5.8.8 on Redhat Linux RHEL 5.5.56 (64-bit)

In reply to DBD::SQLite select fails by bulrush

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.