Does anyone here know how to get a field set to the empty string in Oracle?
My problems is that I'm porting some data from a mysql DB to an Oracle DB. However Oracle seems to think that '' IS NULL (how stupid is that!) so how do I get it to accept SOME value which is close to the empty strin?
My current approach is this, but it doesnt seem to work:
my $odbh = DBI->connect("dbi:Oracle:stuff","xxx","x", { RaiseError =>
+1, PrintError => 1, ChopBlanks => 0 });
my $mdbh = DBI->connect("dbi:mysql:kultur","xxx","x", { RaiseError =>
+1, PrintError => 1 });
$odbh->{ChopBlanks} = 0;
my $msth = $mdbh->prepare("SELECT * FROM atable limit 1");
my $osth = $odbh->prepare("INSERT INTO atable (".(join",",@atablelist)
+.") VALUES (".(join ",",map {"?"} @atablelist).")");
$msth->execute() || die $mdbh->errstr;
while (my $db=$msth->fetchrow_hashref) {
$osth->execute(map {defined $$db{$_} && $$db{$_} eq '' ? " " : $$db{
+$_}} @atablelist) || die $odbh->errstr;
}
Which gives the excellent message:
DBD::Oracle::st execute failed: ORA-01400: cannot insert NULL into ("X
+XX"."ATABLE"."ARROVERSKRIFTSPROG") (DBD ERROR: OCIStmtExecute)
T
I
M
T
O
W
T
D
I