Here's my problem:
I am interfacing an Oracle 8i system with DBI.
I want to insert a record into a table that I got from a file.  The
column that I want to insert into the table is all spaces.  When DBI
passes the insert statement to Oracle I get an error saying 'cannot
insert NULL into' error.  However when I call the quote method on the
variable I get an 'inserted value too large for column' error.
>From checking the dbitrace log file I see that the value passed to
oracle is '<data>'.  It seems that the field is counting the quotes of
the field when computing the field size.
The only solution I have come up with is to do a search/replace on
spaces and put another character in place of them.  However, a field of
all spaces is a valid data condition for my application and needs to be
there.

code:

$sth = $DBH->prepare("INSERT INTO $table VALUES(?, ?, ?, ?, ?, ?, ?,
?)") or die log_message("ERROR: Prepare: " . $DBH->errstr());
while(<INFILE>) {
        # foreach used to quote all space only fields.
        # I've tried it with and without this giving the two errors
above
        foreach $item (@data) {
                if ($item =~ /^\s+$/) {
                        $item = $DBH->quote($item);
                }
        }
        @data = split /$DELIMITER/, $_;
        $sth->execute(@data) or die log_message("ERROR executing insert:
" . $DBH->errstr());
}
        
If anyone has any ideas on how to solve this problem let me know.

Thanks,
Gordon

Reply via email to