I am running into a problem that I have not yet been able to explain. I have code that takes a number, gets the national character code for the number using NCHR, and then performs a RAWTOHEX conversion on it.
It worked in 10g for years. When we upgraded to 11g it started returning different values. I boiled it all down to a few statements, and created a demonstration script:
SET SERVEROUTPUT ON;
DECLARE
rawVar RAW(2000);
nVar NVARCHAR2(1000);
BEGIN
nVar := NCHR(1112);
SELECT RAWTOHEX(nVar) INTO rawVar FROM DUAL;
DBMS_OUTPUT.PUT_LINE('rawVar: ' || rawVar);
END;
/
When executed in 10g, the ouptut is "0458". In 11g (from the same computer and using the same Oracle client software) the output is "00040058". The upstream process that relies on the output is expecting "0458".
Interestingly (to me), if I change the definition of nVar to be an VARCHAR2 instead of an NVARCHAR2, I get "0458" as the output on 11g.
Can someone please help to explain why the results are different? I have searched Oracle's release notes and support system, but have not found any answers.
Many thanks in advance.