CAST in SPL from NVARCHAR[1] to INT
Posted in 2006
Has anyone done this. I'm trying to get the numeric representation of a
unicode character.
DEFINE vpos int;
DEFINE vUnicodeStr NVARCHAR(128);
DEFINE vUnicodeValue int;
DEFINE vUniChar NVARCHAR(1);
DEFINE pFirstName varchar(64);
LET vpos = 1;
LET pFirstName = 'Alan';
LET vUnicodeStr = CAST(pFirstname AS NVARCHAR(128));
LET vUniChar= SUBSTR(vUnicodeStr, vpos, 1);
LET vUnicodeValue = CAST(vUniChar AS INT);
The last line generates this error. The docs talk about CAST only
working when the internal storage is the same. Otherwise a cast support
function is needed. I haven't found much on cast support functions that
would help me write one yet.
1213: Character to numeric conversion error
Error in line 1Near character position 1
[root@nw096a-82 root]# finderr 1213
-1213 A character to numeric conversion process failed.
A character value is being converted to numeric form for storage in a
numeric column or variable. However, the character string cannot be
interpreted as a number. It contains some characters other than white
space, digits, a sign, a decimal, or the letter e; or the parts are in
the wrong order, so the number cannot be deciphered.
If you are using NLS, the decimal character or thousands separator
might be wrong for your locale.
Any ideas appreciated,
Alan