Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I'm trying to write DBI code for Oracle 8.1.7 that uses placeholders. I've tried several variations that I have found on Perlmonks and elsewhere, but none of them work.

Here is what I'm trying to do:

use DBI; use DBD::Oracle; # Define sid, user, password, etc. here my $dbh = DBI->connect($DB_SID, $DB_USER, $DB_PASSWORD, 'Oracle') or die( $dbh->errstr ); my $name = "guppy"; my $sql_statement = 'SELECT foo FROM table_bar WHERE name = ?'; $sth = $dbh->prepare( $sql_statement ) or die( $dbh->errstr ); # This is where I try to replace the placeholder with $name $sth->execute( $name ) or die ( $dbh->errstr ); while( $aref = $sth->fetchrow_arrayref ) { print $aref->[0] ."\n"; } $sth->finish; $dbh->commit; $dbh->disconnect;

When I try to use placeholders, the script runs without any output or errors. The only place where placeholders have worked for me is inside the VALUES() brackets in an INSERT statement. Incidentally, hard-coded SQL statements work just fine. Am I doing something obviously silly? I am new to DBI, so that's quite possible.

In reply to DBI placeholders by randomblue

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

  • 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.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2022-11-28 10:56 GMT
Find Nodes?
    Voting Booth?