none
ms oracle provider ORA-01406 RRS feed

  • Question

  • Hello.

     

    I have a very strange problem, I get  ORA-01406 with the OracleClient.OracleDataReader when selecting from columns with long string. It looks like a bug in the reader itself.

     

    The problem seems to be with varchar2 columns bigger than 2000 characters (you must have a database with national character set = UTF8 for this).

     

    When I select multiple rows that have a total size bigger than 64000 bytes I get ORA-01406.

     

    How to reproduce -

     

    Create the table like this:

    1.     CREATE TABLE tbl (col1 nvarchar2(2001));

    2.     INSERT INTO tbl values (some string with length = 2001, I won’t paste it here J)

    3.     Repeat step 2 until: SELECT SUM(LENGTH(col1)) FROM tbl > 64000

     

    The code is straight forward:

     

    using System.Data.OracleClient;

     

    using (OracleConnection c = new OracleConnection(“connection string”))

    {

        c.Open();

     

        using(OracleCommand cmd = new OracleCommand(“SELECT col1 from tbl”,c))

        {  

            using (OracleDataReader reader = cmd.ExecuteReader())

            {

                while (reader.Read()) // ORA-01406: fetched column value was truncated

                {

                }

            }

        }

    }

     

    This behavior is only reproduced on some computers (it doesn't reproduce on my development machine. But all my clients get it).

     

    Help?

    Monday, September 1, 2008 4:24 PM

Answers

All replies