zoukankan      html  css  js  c++  java
  • DBI-1.634之selectrow_array与fetchrow_array的区别

      在DBI-1.634使用手册里有一个selectrow_array函数,该函数具体说明如下:

      This utility method combines "prepare", "execute" and "fetchrow_array" into a single call. If called in a list context, it returns the first row of data from the statement. The $statement parameter can be a previously prepared statement handle, in which case the prepare is skipped.

      手册里说明该函数具备与fetchrow_array类似的功能。在实际使用时,确实有区别的。如下例子:

      

     1 #!/bin/env perl
     2 use DBI;
     3 
     4 my $dbh=DBI->connect("dbi:Oracle:gzgldb","nrmdb","nrmoptr123") or die "connect db error!";
     5 
     6 my $sql='select * from router';
     7 
     8 my $sth=$dbh->prepare($sql);
     9 
    10 $sth->execute() or die "execute sql error!";
    11 
    12 my @row1=$sth->fetchrow_array();
    13 print "@row1 
    ";
    14 @row1=$sth->fetchrow_array();
    15 print "@row1 num2 
    ";
    16 
    17 my @row=$dbh->selectrow_array($sql);
    18       print "@row
    ";
    19 
    20 @row=$dbh->selectrow_array($sql);
    21 
    22       print "@row
    ";
    23 
    24 
    25 $sth->finish;
    26 $dbh->disconnect();

    以下为输出结果:

    由此可以看出fetchrow_array每取一次,行指针会下移一次;而selectrow_array确不会这样做。

  • 相关阅读:
    linux kernel ftrace 之wakeup tracer and wakeup_rt tracer
    urb传输的代码分析
    open/ioctl in kernel
    淺談C51記憶體優化(data idata xdata)
    8051 XDATA
    Android.bp
    android bionic
    echo +80 > /sys/class/rtc/rtc0/wakealarm
    高清地图下载
    更新和删除数据
  • 原文地址:https://www.cnblogs.com/ZeroTiny/p/4737002.html
Copyright © 2011-2022 走看看