Hail, great masters. I have returned after a long sojourn, in which I have traveled far in the paths of Perl, but am still very much a novice.

I am especially a newb to database work, and am trying to catch myself up. I feel like I am probably making a very simple and laughable mistake, so I only come to you after hours spent beating my head against this in futility, much google-searching, and throwing up my hands.

I am working with SQLite3 and DBD::SQLite (on WinXP, with ActivePerl 5.14.2), and have a fairly simple situation in which I have a table "profile," with integer primary key "profile_id", and another column "name". I want to do lookups on this table by "name", so I created an index "idx_name":

CREATE INDEX idx_name ON profile (name COLLATE NOCASE DESC);

Queries on this index work just fine when testing them on the SQLite command line:

SELECT profile_id ON profile INDEXED BY idx_name WHERE name == 'William';

However, when I try to run this in Perl, I get an error:

use strict; use warnings 'all'; use DBI; my $dbh = DBI->connect("dbi:SQLite:test.db","",""); my $sql = q{ SELECT profile_id FROM profile INDEXED BY idx_name WHERE +name == ? }; my $sth = $dbh->prepare($sql); my $name = 'William'; my $rc = $sth->execute($name);
DBD::SQLite::db prepare failed: cannot use index: idx_name

What am I doing wrong? I appreciate your patience.


In reply to "Cannot use index" with DBD::SQLite by LonelyPilgrim

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.