Home » SQL & PL/SQL » SQL & PL/SQL » raise_application_error function and unicode problem
raise_application_error function and unicode problem [message #187463] Mon, 14 August 2006 02:17 Go to next message
khosravi
Messages: 68
Registered: April 2006
Member
Hello to all

I have written a procedure in oracle and in this procedure i have used raise_application_error function for raising exception
but in message parameter of this function i have used persian
text now when i execute this procedure in iSQL*Plus this
execute fine and i can see exception message in persian
but when i call the procedure in C#.Net persian exception message appear such this?

Verify below example:

procedure:
CREATE OR REPLACE PROCEDURE ali_p2(p_id number,p_salary out nvarchar2)
IS
excep1 EXCEPTION;
BEGIN
IF p_id=1 THEN
  p_salary:='هیچ رکوردی پیدا نشد';
ELSE
  RAISE excep1;
END IF;

EXCEPTION
  WHEN excep1 THEN    
       raise_application_error(-20000,N'هیچ رکوردی پیدا نشد');
      
end ali_p2;
/


In isql*plus:
var u1 nvarchar2(50);
execute ali_p2(4,:u1);

result---->

ERROR at line 1:
ORA-20000: هیچ رکوردی پیدا نشد ORA-06512: at
"ALI.ALI_P2", line 13
ORA-06512: at line 1 


C#.NET sample:
/*  private System.Data.OracleClient.OracleConnection 
      oracleConnection1;
  private System.Data.OracleClient.OracleCommand 
      oracleCommand1;
  private System.Windows.Forms.Button button1;
  private System.Windows.Forms.TextBox textBox1;*/

private void button1_Click(object sender, System.EventArgs e)
{

  oracleCommand1.Parameters[0].Value=0;
  oracleCommand1.Connection.Open();
  try
    {
    oracleCommand1.ExecuteNonQuery();
    textBox1.Text=oracleCommand1.Parameters[1].Value.ToString();                       
    }
    catch(System.Data.OracleClient.OracleException ex1)
    {
	textBox1.Text=ex1.Message.ToString();						
     }

}

result------>
ORA-20000: żżż żżżżżż żżżż żżż
ORA-06512: at "ALI.ALI_P2", line 13
ORA-06512: at line 1


Please, if you can help me?

Thanks.
Re: raise_application_error function and unicode problem [message #187635 is a reply to message #187463] Mon, 14 August 2006 14:49 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
The first place to probably look is the codepage setting used by .NET's Oracle driver. The codepage setting needs to be compatible (not necessarily 100% the same) at your database characterset.

You should also try writing a simple .NET program to print that string directly to make sure that the Windows codepage can support what you are trying to print.

Previous Topic: Function
Next Topic: Matrix with dates/time
Goto Forum:
  


Current Time: Wed Dec 07 07:09:39 CST 2016

Total time taken to generate the page: 0.17155 seconds