Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I've been bouncing some ideas around after reading these: Tao::DBI::st, DBIx::bind_param_inline, Method::Signatures, Devel::Declare, DBI recipes#Binding columns and fetching
SELECT $dbh, ":name, :email from ... where DIAPER=?", 'soft and absorbant' { print "$name < $email >\n"; }
SELECT $dbh, " :name, :email from ... where DIAPER LIKE ? ", 'soft and absorbant' { print "$name < $email >\n"; }
SELECT $dbh, ":name, :email from ... where DIAPER=?", 'soft and absorbant' { print "$name < $email >\n"; }
SELECT $dbh, " :name, :email from ... where DIAPER LIKE ? ", 'soft and absorbant' { print "$name < $email >\n"; }
$dbh->SELECT ":name, :email from ... where DIAPER=?", 'soft and absorbant' { print "$name < $email >\n"; }
$dbh->SELECT " :name, :email from ... where DIAPER LIKE ? ", 'soft and absorbant' { print "$name < $email >\n"; }
$dbh->SELECT( ":name, :email from ... where DIAPER=?", 'soft and absorbant', sub { print "$name < $email >\n"; });
$dbh->SELECT( " :name, :email from ... where DIAPER LIKE ? ", 'soft and absorbant', sub { print "$name < $email >\n"; } );
for my $quality ( 'soft', 'absorbant' ){ SELECT ":rec{name}, :rec{email} from ... where DIAPER=?", $quality + { print "$rec{name} < $rec{email} >\n"; } }
Say these are lines 2 3 4 5 6 in file foo.pl
for my $quality ( 'soft', 'absorbant' ){ SELECT ":{name}, :{email} from ... where DIAPER=?", $quality { print "$rec{name} < $rec{email} >\n"; } }
So through some Devel::Declare type magic that becomes
{ my %rec = ( name => undef, email => undef, ); # line 3 foo.pl my $sth = $dbh->prepare( "SELECT name, email from ... where DIAPER +=?" ); # line 3 foo.pl $sth->execute( $quality ); $sth->bind_col(1, \$rec{name}); $sth->bind_col(2, \$rec{email}); while( $sth->fetchrow_arrayref ){ # line 4 foo.pl print "$rec{name} < $rec{email} >\n"; } } # line 7 foo.pl

But my thinking isn't clear, any ideas?


In reply to Devel::Declare type syntactic sugar for DBI select bind_col param by Anonymous Monk

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2014-07-26 04:43 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (175 votes), past polls