in reply to db prepare failed:invalid character error : Perl DBI - Help plz

Does that SQL work when you paste it into your command line SQL client?

Many SQL dialects do not like double quotes (""), and I think that Oracle does not like these. Also, you should use placeholders in your SQL statements or at least use DBI->quote.

Using placeholders, your code would look similar to this:

my $sth1 = $db->prepare("SELECT ... FROM WF_WORKFLOW WHERE .... = ?") +; # Japanese characters elided $sth1->execute($scode1); my @results = $sth1->fetchall_arrayref({});

Replies are listed 'Best First'.
Re^2: db prepare failed:invalid character error : Perl DBI - Help plz
by srini_sun (Initiate) on Oct 15, 2007 at 07:57 UTC
    Hi Corion, Thanks for your response. Actually I am using place holders in my code.. Below is my code.. But still I am getting the error....Below is my code #!/usr/bin/perl use DBI; $ACCDBHOST = "host"; $ACCDBDB = "db"; $ACCDBUSER = "user"; $ACCDBPWD = "pwd"; $db = DBI->connect("DBI:Oracle:host=$ACCDBHOST;sid=$ACCDBDB",$ACCDBUSE +R,$ACCDBPWD); unless($db) { print "(ERROR) Failed to connect to $ACCDBHOST."; exit(1); } $scode = 198000031; my $sth1 = $db->prepare("SELECT 一時上司社員番号 FROM WF_WORKFLOW WHER +E 本人社員番号 = ?"); $sth1->bind_param(1,$scode1); $sth1->execute(); my $row1; while ( $row1 = $sth1->fetchrow_array( ) ) { print $row1; } $sth1->finish(); $db->disconnect();
    Thanks Sri
      And are you saying that this is the exact code that produced the error message you showed us at the top of the thread?

      Have you tried redirecting stderr to a file? You may need to inspect the error message for non-printable byte values (e.g. using od or xxd or some other hex-dump tool).

      Does the Japanese version of Oracle actually support Japanese strings as column names in the database schema? What character encoding does it use? What version of perl are you using? How certain are you that the encoding used in the perl script matches what is used in the Oracle schema?