G'day Bod,

I tried to reproduce your problem but couldn't.

I created a test database:

$ sqlite3 bod SQLite version 3.34.0 2020-12-01 16:14:00 Enter ".help" for usage hints. sqlite> create table Person (idPerson, email, altEmail); sqlite> insert into Person values (1, 'you@example.com', ''); sqlite> insert into Person values (2, '', 'me@example.com'); sqlite> insert into Person values (3, 'me@example.com', ''); sqlite> select * from Person; 1|you@example.com| 2||me@example.com 3|me@example.com| sqlite>

Then a test script:

#!/usr/bin/env perl use strict; use warnings; use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=bod"); print "Contents of Person:\n"; eval { print join('|', @$_), "\n" for $dbh->selectall_array('select * fro +m Person'); 1; } or do { print $dbh->errstr, "\n"; }; print "Head-scratching code:\n"; eval { my %data = (email => 'me@example.com'); my $crid = $dbh->selectrow_array("SELECT idPerson FROM Person WHER +E email = ? OR altEmail = ?", undef, $data{'email' }, $data{'email'}); print "$crid\n"; 1; } or do { print $dbh->errstr, "\n"; };

Output:

Contents of Person: 1|you@example.com| 2||me@example.com 3|me@example.com| Head-scratching code: 2

As you can see, I had to make some guesses; however, I used a verbatim copy of your selectrow_array(). It correctly found the idPerson (i.e. 2) using your parameters.

Instead of presenting us with bits of isolated code, please provide an SSCCE that reproduces your problem and is written in such a way that we can run it and help you towards a solution.

What you could also do is create a temporary directory and, in there, create the test database exactly as I have and run exactly the same test script I presented; then compare the output.

— Ken


In reply to Re: Recalcitrant placeholders by kcott
in thread Recalcitrant placeholders by Bod

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.