Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Jim--
I'm starting to feel like a broken record, because most of the SoPWs I answer are about DBI, and my advice usually consists of either:

  • read the docs (which I assume you've done :)
  • consider using $dbh->quote() and $dbh->quote_identifier(), which it appears you haven't.
  • The whole reason I discovered these two methods was in trying to prepare dynamic sql statements, much like you're doing here. I would suggest that you try to apply $dbh->quote_identifier() to the names of any tables or columns, and $dbh->quote() to any values you're using. Try to do the join after these methods have been applied, and you might be successful.

    One consideration is that you seem to be using placeholders. While this is encouraged and can greatly speed up your queries, I've found that it's sometimes difficult to generate queries that are dynamic both at the level of the structure of the query (table names and columns) and at the specific values in the query (using ? as a placeholder for values). While the docs say that specifying a value as a parameter to $dbh->execute() will automatically quote it appropriately, I just haven't had much luck with my attempts. If you continue to have problems, consider rewriting the queries to use explicit values instead of placeholders. Not optimal, but if it works it might give you a place to start debugging from (and a functioning application! :)

    No post of mine regarding DBI would be complete without referring to chromatic's DBI is OK, which was my most valuable resource in moving out of the beginner stages of using DBI. He uses clever quoting and map combinations to dynamically generate queries, and also talks about using placeholders. You should definitely check it out if you haven't.

    good luck with your project, feel free to reply with any questions
    --au


    In reply to Re: DBI execute() args in array format (or similar) possible? by aufrank
    in thread DBI execute() args in array format (or similar) possible? by snafu

    Title:
    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?
    Username:
    Password:

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

    How do I use this?Last hourOther CB clients
    Other Users?
    Others cooling their heels in the Monastery: (3)
    As of 2024-04-26 00:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found