I am capable of retrieving multi byte characters (Chinese) from the Oracle database by simply putting TOraSession.Options.UseUnicode to True. I am showing the values by the use of Unicode Components for Delphi. Works perfect!
Now I also need to be able to insert multi byte characters. Again i use the Unicode Components (the Text property of this component is of type WideString).
As the SQL property of TOraQuery is of type TStrings all my multi byte characters turn into question marks.
Is there a solution for this which I have overlooked??
Many thanks!
WideStrings in SQL property of TOraQuery (Unicode,Chinese)
You can use parameters to insert Chinese characters. For example:
Code: Select all
OraQuery.SQL.Text := 'insert into table1(f1) values (:f1)';
OraQuery.ParamByName('F1').ParamType := ptInput;
OraQuery.ParamByName('F1').DataType := ftWideString;
OraQuery.ParamByName('F1').AsWideString := TntEdit1.Text;
OraQuery.Execute;
First of all, may thanks for your quick response explaining how we should deal with this!
I am not sure how to create parameters in design time so I used the CreateParam function to create the parameter and set its properties. I first tried the following:
In the Init of my Datamodule I put:
OraQuery.Params.Clear();
OraQuery.Params.CreateParam(ftWideString, 'f1', ptInput);
Calling the Insert:
OraQuery.SQL.Text := 'insert into table1(f1) values (:f1)';
OraQuery.ParamByName( 'f1' ).AsWideString := Edit1.Text;
OraQuery.Execute;
The first time I call the procedure containing the Insert it indeed works (that’s a relief
)!
Second time (and following), again question marks are written into the DB.
I have to extend the Insert procedure to make it work:
OraQuery.SQL.Text := 'insert into table1(f1) values (:f1)';
ParamByName( 'f1' ).ParamType := ptInput;
ParamByName( 'f1' ).DataType := ftWideString;
OraQuery.ParamByName( 'f1' ).AsWideString := Edit1.Text;
OraQuery.Execute;
How come the parameter losses its settings?
I am not sure how to create parameters in design time so I used the CreateParam function to create the parameter and set its properties. I first tried the following:
In the Init of my Datamodule I put:
OraQuery.Params.Clear();
OraQuery.Params.CreateParam(ftWideString, 'f1', ptInput);
Calling the Insert:
OraQuery.SQL.Text := 'insert into table1(f1) values (:f1)';
OraQuery.ParamByName( 'f1' ).AsWideString := Edit1.Text;
OraQuery.Execute;
The first time I call the procedure containing the Insert it indeed works (that’s a relief

Second time (and following), again question marks are written into the DB.
I have to extend the Insert procedure to make it work:
OraQuery.SQL.Text := 'insert into table1(f1) values (:f1)';
ParamByName( 'f1' ).ParamType := ptInput;
ParamByName( 'f1' ).DataType := ftWideString;
OraQuery.ParamByName( 'f1' ).AsWideString := Edit1.Text;
OraQuery.Execute;
How come the parameter losses its settings?
Parameters are created automatically when you assign a value to SQL property. You don't need to call Clear and CreateParam method.
You only need to set ParamType and DataType properties. You should assign values to SQL property of TOraQuery and to ParamType and DataType properties of TOraParam only once, for example, in the initialization of your datamodule.
To insert a value you need only assign this value to AsWideString property and call Execute method.
At design time double click the TOraQuery component to open the TOraQuery editor. Write SQL and then go to Parameters tab. You can set ParamType and DataType properties of parameters there.
You only need to set ParamType and DataType properties. You should assign values to SQL property of TOraQuery and to ParamType and DataType properties of TOraParam only once, for example, in the initialization of your datamodule.
To insert a value you need only assign this value to AsWideString property and call Execute method.
At design time double click the TOraQuery component to open the TOraQuery editor. Write SQL and then go to Parameters tab. You can set ParamType and DataType properties of parameters there.