In pretty much any normal programming language, one can cast an integer/short/byte into a char with ease using a cast similar to this
char alpha = (char)123;
I am trying to do this in an Oracle database. I have column of type CHAR(1 BYTE) and I want to be able to store NUMBER values (non of which will be larger than around 30) in it. The CAST function isn’t letting me do it.
rank := 10;
CAST(rank as CHAR(1))
where rank is a NUMBER variable. I get an error:
Value from cast operand is larger than cast target size.
How is this done in Oracle PL/SQL?
As per my comment on @northpole’s answer…
The closest to what you want might not be exactly correct but the CHR function would convert the numeric to it’s ascii equivalent.
i.e.
alpha := chr(113);would put the char “q” into the alpha variable thereby storing your numeric “113” as a single byte.