My first suggestion is to always, always check the status of your DBI calls, like so:
my $sth=$dbh->prepare($MYSQL) or die "Could not prepare $MYSQL: $DBI:: +errstr\n"; ...etc. for all connects, executes, etc.
As far as passing spaces, that should not be a problem. When you execute the query, the DBI should quote it for you. Try adding the line
$dbh->trace(2);
at the top of your script (after $dbh is created, of course) to see some of the details of what is going on. You could also use the 'quote' function to see exactly what it is sending:
my $string = "find me"; my $newstring = $dbh->quote($string) or die "Could not quote $string: +$DBI::errstr\n"; print "($string) has become ($newstring)\n";
('quote' is mostly used to help escape characters like a single apotrophe, which has special meaning inside SQL.)

Finally, consider moving your SQL statements into a variable: it will read better, be easier to maintain, and eliminate double typing of the same string in multiple places:

my $bazfind = shift || "12"; print "Looking for $bazfind.\n"; my $dbh=DBI->connect($SID, $user, $pass, {AutoCommit=>1}) or die "Could not connect to $SID: $DBI::errstr\n"; my $FOOBAR_SQL = "SELECT FOO FROM BARVILLE WHERE BAZ=?"; my $sth=$dbh->prepare($FOOBAR_SQL) or die "Could not prepare $FOOBAR_SQL: $DBI::errstr\n"; $sth->execute($bazfind) or die qq!Could not execute $FOOBAR_SQL with "$bazfind": $DBI::errst +r\n!; ...etc. etc.
Note how the single declaration of $FOOBAR_SQL not only saves typing it in repeated times, but looks nicer too.

In reply to Re: Perl/DBI/Oracle and strings with spaces by turnstep
in thread Perl/DBI/Oracle and strings with spaces by Majik

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.