DBI Fetch

2012年9月10日 Perl
# DBIを使用する時のメモ
#/usr/bin/perl
use DBI;

my $sql = qq|select value1 , value 2, value3 |;
  $sql .= qq|from table_name |;
  $sql .= qq|where value1 = :1 |;
  $sql .= qq|and value2 = :2 |;

my $sth = $dbh->prepare($sql);
  $sth->bind_param(1,$param1);
  $sth->bind_param(2,$param2);
  $sth->execute;

my @array = ();
my $var = $sth->fetchall_arrayref();
foreach(@$var){
  #push(@array,@$_);
  $value1 = $$_[0];
  $value2 = $$_[1];
  $value3 = $$_[2];
  push(@array,qq|$value1,$value2,$value3|);
}

exit;

コメント

最新の日記 一覧

<<  2025年6月  >>
1234567
891011121314
15161718192021
22232425262728
293012345

お気に入り日記の更新

この日記について

日記内を検索