I'm pretty sure I don't understand what you're asking. In general, the best way to "interpolate" values into an sql query is by using placeholders with DBI.

If you want this literal string of eight characters - $in{cid} - to be the value being tested in the where clause, you could do it like this:

my $dbh = DBI->connect( $whatever… ) ... my $sth = $dbh->prepare( "select field from table where id != ?" ); $sth->execute( '$in{cid}' ); # an 8-character string is the placehold +er value ...
On the other hand, if $in{cid} is an actual hash element in your script, and it happens to contain a string or number that you want to use as the value to be tested in the where clause, then:
my %in; $in{cid} = "something"; my $dbh = DBI->connect( $whatever… ) ... my $sth = $dbh->prepare( "select field from table where id != ?" ); $sth->execute( $in{cid} ); # the hash element value is the placeholde +r value ...
Did you have something in mind other than these two cases?

Sorry - I'll try to respond again, now that I understand the question.


In reply to Re: How to interpolate sql-output by graff
in thread How to interpolate sql-output by Seq

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.