sqlbashingres

Does blobstor hava an opposite command, Ingres?


I am using the blobstor command to load jpeg images into an ingres db, which is fine. But at some point I need to develop a manual way to copy them back out again.

I can find some examples of this that uses BCP, however these are for sql server db's. So my question is, does blobstor have an equal an opposite command to extract blobs, that can be used when select from an Ingres db. Pointers to any examples would be much appreciated.


Solution

  • I don't believe there is a blobstor-opposite tool which ships with Ingres, when I've had need for such a thing before now the solution was to write a short program.

    As an example, here's a perl script. It uses DBI and the DBD-IngresII module. Hope it's of some use.

        # 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;