srini_sun has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I am connecting to database using DBI . My csutomer has a oracle table + in that all columns are in japanese. I run this program in Solaris O +S Japanese version. I am getting the below error DBD::Oracle::db prepare failed: ORA-00911: invalid character (DBD ERRO +R: error possibly near <*> ind = "1980031""] at accdb.pl line 22.CT裔・ in this line my $sth1 = $db->prepare("SELECT 一時上司社員番号 FROM WF_WORKFLOW WHER +E 本人社員番号 = \"$scode1\""); I tried to pass differnt values to $scode1 but nothing happening. Please help me. I am stuck. Thanks Sri

Replies are listed 'Best First'.
Re: db prepare failed:invalid character error : Perl DBI - Help plz
by Corion (Patriarch) on Oct 15, 2007 at 07:03 UTC

    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({});
      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?

Re: db prepare failed:invalid character error : Perl DBI - Help plz
by moritz (Cardinal) on Oct 15, 2007 at 08:13 UTC
    Try to use utf8; and make sure your script's source code is utf8 encoded.
    A reply falls below the community's threshold of quality. You may see it by logging in.