TOracleConnection causes ORA-01406
Original Reporter info from Mantis: Stanislav Kaskevich
-
Reporter name: Stanislav Kaskevich
Original Reporter info from Mantis: Stanislav Kaskevich
- Reporter name: Stanislav Kaskevich
Description:
I porting some projects from windows to linux and encountererd that TOracleConnection wrongly count max size of bind buffers in situation when server uses 1 byte encoding and client uses unicode encoding. In my case server NLS_LANG=AMERICAN_AMERICA.CL8MSWIN1251 and client NLS_LANG=AMERICAN_AMERICA.UTF8
I think situation will be reproduced in all cases of 1 byte server charset that uses diacritical signs (such as french) and client unicode charset (UTF8 or AL32UTF8). I'm using svn versions of fpc and lazarus.
Additional information:
Example statement that causes ORA-01406:
SELECT 'проверка' FROM DUAL;
SELECT SYSDATE FROM DUAL; -- cases same oracle error, because wrongly defined FieldDef for oracle field type OCI_TYPECODE_DATE
I've patched oracleconnection.pp to use internally unicode environment. That resolve issue.
But I don't know what direction will be right:
- Add oracle unicode environment support via e.g. #IFDEF ORA_USEUNICODE or 2. Using TOracleConnection Params property. In last case we'll got flexibility, but I aware of messing TStringField and TWideStringField in big project code.
While looking throu sqldb sources I found that TWideStringField.AsString
simply casts WideString to String. Is it right behaviour? Since Lazarus use internally utf8 may be TWideStringField.AsString shoud return Utf8Encode(AsWideString)? Yet another finding: TStringField hasn't AsWideString property.
I attached patched oracleconnection.pp for your conclusion.
Mantis conversion info:
- Mantis ID: 16529