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

In reply to Oracle DBI quote by Cine

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.