views:

498

answers:

1

My Oracle database returns the error:

ORA-12899 - Value too large for column TIT.ESTADO_CIVIL (actual: 2, maximum: 1)

But I'm very sure that the sended value is an unique char 'C'.

Anyone knows why this is happening?

(I'm using C# with ODP.NET)

+3  A: 

"The C# char has 16 bits; googling tells me that Oracle CHAR types are 8 bits."

There are a couple of ways of dealing with this. The best solution would be to fix the database so it uses character semantics.

alter system set nls_length_semantics = char
/ 

As this has major ramifications you need to be sure that it solves your problem. Modify your table to use character semantics and see whether it removes the ORA-12899 exceptions.

SQL> create table t69 (col1 char(1 byte))
  2  /

Table created.

SQL> desc t69
 Name          Null?    Type
 ------------- -------- ----------------
 COL1                   CHAR(1)


SQL> alter table t69 modify col1 char(1 char)
  2  /

Table altered.

SQL> desc t69
 Name          Null?    Type
 ------------- -------- ----------------
 COL1                   CHAR(1 CHAR)

SQL>

The documentation has a lot of helpful information on globalization and character sets. You don't say which version of the database you're using, so here's a link to the 9i docs on Length Semantics.

APC