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 linemy $sth=$dbh->prepare($MYSQL) or die "Could not prepare $MYSQL: $DBI:: +errstr\n"; ...etc. for all connects, executes, etc.
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:$dbh->trace(2);
('quote' is mostly used to help escape characters like a single apotrophe, which has special meaning inside SQL.)my $string = "find me"; my $newstring = $dbh->quote($string) or die "Could not quote $string: +$DBI::errstr\n"; print "($string) has become ($newstring)\n";
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:
Note how the single declaration of $FOOBAR_SQL not only saves typing it in repeated times, but looks nicer too.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.
In reply to Re: Perl/DBI/Oracle and strings with spaces
by turnstep
in thread Perl/DBI/Oracle and strings with spaces
by Majik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |