Oddity using placeholders w/ Oracle

From: Steven Lembark (lembark_at_wrkhors.com)
Date: 07/24/04


Date: Fri, 23 Jul 2004 18:28:38 -0400
To: dbi-users <dbi-users@perl.org>


Maybe I've just missed a known bug, but this seems kinda odd...

The code below is running againsed Oracle-9.2.0.4 on RHE-3.0.
Called with the same variable interpolated and as a placeholder
it works or doesn't. I have any amount of code floating around
here that uses placeholders and DOES work...

Any suggesions?

$ perl example;

        DBI Version: 1.43

        DBD Version: 1.15

        Value is: 'Q8R2H7'

        Result A: '133387'

        Result B: ''

$ cat example;

use DBI;
use DBD::Oracle;

use Data::Dumper;

print "\n\tDBI Version: $DBI::VERSION\n";
print "\n\tDBD Version: $DBD::Oracle::VERSION\n";

my @connect_args =
(
        "dbi:Oracle:host=$ENV{ORACLE_HOST};sid=$ENV{ORACLE_SID}",
        $ENV{ORACLE_USER},
        $ENV{ORACLE_PASS},
        {
                RaiseError => 1
        }
);

my $dbh = DBI->connect( @connect_args );

my $value = 'Q8R2H7';

print "\n\tValue is: '$value'\n";

my $a =
qq{
        select entry_id
        from entry
        where entry_accno = '$value'
};

my $b =
q{
        select entry_id
        from entry
        where entry_accno = ?
};

{
        # this works...

        my $handle_a = $dbh->prepare( $a );

        $handle_a->execute;

        my @row = $handle_a->fetchrow_array;

        print "\n\tResult A: '@row'\n";
}

{
        # this doesn't

        my $handle_b = $dbh->prepare( $b );

        $handle_b->execute( $value );

        my @row = $handle_b->fetchrow_array;

        print "\n\tResult B: '@row'\n";
}

-- 
Steven Lembark                           9 Music Square South, Box 344
Workhorse Computing                                Nashville, TN 37203
lembark@wrkhors.com                                     1 888 359 3508


Relevant Pages

  • Re: Oddity using placeholders w/ Oracle
    ... > Maybe I've just missed a known bug, but this seems kinda odd... ... > Called with the same variable interpolated and as a placeholder ...
    (perl.dbi.users)
  • Double status bar in VICE
    ... joystick indicators are in the second line? ... A bug or a placeholder for other status messages I haven't encountered ... Prev by Date: ...
    (comp.emulators.cbm)