Hi! First of all sorry for my bad english =) I've just started learning DBI, and faced a problem with bind_columns usage. So..here is my code
BEGIN { $ENV{DBI_SQL_NANO} = 1 } use DBI; use DBI::SQL::Nano; my $dbh = DBI->connect('DBI:DBM(RaiseError=1):'); my $query = "CREATE TABLE socks (id TINYINT NOT_NULL AUTO_INCREMENT, i +p VARCHAR(12), port INT,country CHAR(2))" and sql_exec(0,$query); sub sql_exec(0,$query) {....} #sql_exec is my subroutine, which takes 2 args first #boolean, which d +efines 0 non-select query, or 1 select #query respectively, and a que +ry itself, and makes #a standard $sql = $dbh->prepare($query) || die( +$dbh->errstr); # $sql->execute || die($sql->errstr); etc.. $query = "INSERT INTO socks (id,ip,port,country) VALUES (1,180.118.232 +,8080,US)" and sql_exec(0,$query);#no problem #and on binding a select query result we got stuck..for #example $query = "SELECT (id,ip,port,country) FROM socks where id = 1"; $sql = $dbh->prepare($query) || die($dbh->errstr); my ($id,$ip,$country); $sql->bind_columns(\($id,$ip,$port,$country)); $sql->execute || die($sql->errstr); while($sql->fetch) { print "id=>$id, ip=>$ip, port=>$port, country=>$country\n"; } And on a DBI->trace(4); i've got smth like <- fetch= [ '1' '180.118.232' undef ] and on insert i've got -> prepare in DBD::File::db for DBD::DBM::db (DBI::db=HASH(0x80106e440 +)~0x80106e3c0 'INSERT INTO socks (id,ip,port,country) VALUES (1,180.1 +18.232,8080,US)') thr#80100b000 <> FETCH= 'DBD::DBM::st' ('ImplementorClass' from cache) at /usr/l +ocal/lib/perl5/site_perl/5.8.9/mach/DBD/File.pm line 179 via at clic +k.pl line 25 -> STORE in DBD::File::st for DBD::DBM::st (DBI::st=HASH(0x8019a33 +10)~0x80235dcd0 'f_stmt' DBD::DBM::Statement=HASH(0x80235dc20)) thr#8 +0100b000 <- STORE= 1 at /usr/local/lib/perl5/site_perl/5.8.9/mach/DBD/File. +pm line 206 via at click.pl line 25 -> STORE for DBD::DBM::st (DBI::st=HASH(0x8019a3310)~0x80235dcd0 ' +f_params' ARRAY(0x80235ddd0)) thr#80100b000 <- STORE= 1 at /usr/local/lib/perl5/site_perl/5.8.9/mach/DBD/File. +pm line 207 via at click.pl line 25 -> STORE for DBD::DBM::st (DBI::st=HASH(0x8019a3310)~0x80235dcd0 ' +NUM_OF_PARAMS' 0) thr#80100b000
I just cant understand where the problem is.. Thanks a lot in advance!

In reply to DBI and bind_columns again by gemoroy

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.