Hi,
Having the same discussion on OTN. The output from sqlplus is as follows
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> create table test_table (test_column char(8 byte));
Table created.
SQL> insert into test_table
2 values ('NZ07100S');
1 row created.
SQL> commit
2 /
Commit complete.
SQL> create or replace function gettestvalue
2 return test_table.test_column%type
3 is
4 test_value test_table.test_column%type;
5 begin
6 select max(test_column) into test_value from test_table;
7 return test_value;
8 end;
9 /
Function created.
SQL> select gettestvalue from dual
2 /
select gettestvalue from dual
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "JEGA.GETTESTVALUE", line 6
SQL> spool off
Also, the output from the length of the values is as follows
SQL> select lengthb (TEST_COLUMN)
2 from test_table
3 where test_column = 'NZ07100S'
4 /
LENGTHB(TEST_COLUMN)
--------------------
8
SQL> select max (lengthb (test_column))
2 from test_table
3 /
MAX(LENGTHB(TEST_COLUMN))
-------------------------
8
A couple of the users on OTN have also been testing this case, and so far we have not noticed it on Oracle Enterprise Edition. Changing the data type to varchar(8) does seem to solve the problem.
SQL> alter table test_table modify test_column varchar2 (8 byte);
Table altered.
SQL> select gettestvalue from dual;
GETTESTVALUE
--------------------------------------------------------------------------------
NZ07100S
SQL> spool off;
It does seem to be a problem that is unique to XE. Still trying to figure out if this is a known issue. Since XE is used by the developers for development and testing purposes, I guess we should be alright as the Production Database is running Enterprise edition. However, it does seem odd for this problem to occur