0

我正在使用 blobstor 命令将 jpeg 图像加载到 ingres db 中,这很好。但在某些时候,我需要开发一种手动方式将它们再次复制回来。

我可以找到一些使用 BCP 的示例,但是这些示例适用于 sql server db。所以我的问题是,blobstor 是否有一个相等的相反命令来提取 blob,可以在从 Ingres db 中选择时使用。指向任何示例的指针将不胜感激。

4

1 回答 1

1

我不相信 Ingres 附带了一个 blobstor-opposite 工具,当我以前需要这样的东西时,解决方案是编写一个短程序。

例如,这是一个 perl 脚本。它使用 DBI 和 DBD-IngresII 模块。希望有点用。

    # Required: db=, table=, col=.  Optional: user=.
    # Anything else is a where clause.
    use DBI;
    my %p=(); my $where="";
    foreach my $arg (@ARGV)
    {
      if ($arg =~ /(db|table|col|user)=(\S+)$/) { $p{$1}=$2; next; }
      $where .= " ".$arg if($p{db} and $p{table} and $p{col});
    }
    die "db, table and col required.\n" if(!$p{db} or !$p{table}
      or !$p{col});
    my $user=""; $user=$p{user} if defined($p{user});
    my $dbh=DBI->connect("dbi:IngresII:".$p{db},$user,"");
    my $stm="select ".$p{col}." from ".$p{table};
    $stm.=" where".$where if ($where ne "");
    my $sth=$dbh->prepare($stm);
    $sth->execute;
    @row=$sth->fetchrow_array;
    print $row[0];
    $sth->finish;
    $dbh->disconnect;
于 2016-07-26T11:27:16.440 回答