Hi-

I'm working with DBI to set up a suite to test Oracle datatypes. My scripts for BLOB's/CLOB's work fine, but I'm running into problems with RAW datatypes. I'm trying to insert 5-6 .GIF files. I think they insert o.k., but when I select them back out, they have different file sizes and appear to have been corrupted somehow. How should I specify a RAW datatype within my scripts, whether select or insert?

***** insert snippet:
my $max_len = 20000; # #Load Filenames into Scalar # opendir(DIR, "/RAWdata") || die "Cannot open gif:$!\n"; my @filenames = grep !/^\./, readdir(DIR); close(DIR); my $file; # #Go through list of filenames in a directory #Add the name, length, and binary data to the table # foreach my $title (@filenames) { open(FILE, "/RAWdata/$title") || die "Cannot open $title : $!\n"; binmode FILE; my $file_len = read FILE, $file, $max_len; #Prepare Insert Statement my $sth = $dbh->prepare("INSERT into RAH values (?,?,?)" ); #Bind Variables to columns. $sth->bind_param(1,$title); $sth->bind_param(2,$file_len); $sth->bind_param(3,$file, {ora_type => ORA_RAW} ); #Insert. my $rv = $sth->execute(); close(FILE); }
***** select snippet:
$dbh->{LongReadLen} = '20000'; opendir(DIR, "/RAWdata") || die "Cannot open gif:$!\n"; my @filenames = grep !/^\./, readdir(DIR); close(DIR); my $title; # #Select out RAW's based on their filename - R_NAME # foreach my $title (@filenames) { my $sth = $dbh->prepare("SELECT R_RAW from RAH where R_NAME='$t +itle'"); $sth->execute(); # #Put selected RAW into an array, write it to a file using the filename + you #got from the RAWdata directory. # my @jpg = $sth->fetchrow_array(); open(FILE, ">$title") || die "Cannot open file for writing: $!\ +n"; print FILE @jpg; close(FILE); $sth->finish();

Edit kudra, 2001-10-19 Replaced br with code


In reply to DBD::Oracle - RAW datatypes by teads

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.