6 Replies Latest reply: Aug 19, 2014 1:51 PM by Alex.Keh .Product.Manager-Oracle RSS

    ODP.NET DRIVER SWAPS YEAR AND CENTURY

    2730976

      Hi

       

      I am using OracleBulkCopy to load oracle data. I am passing IDatareader to WritetoServer(myDataReader) method. Everything works fine except the date. When i query the database table see that century and year are being swapped. Is it a bug in driver ? I would apprecaite if someone could please explain this behavious

       

       

      Thanks in advance

        • 1. Re: ODP.NET DRIVER SWAPS YEAR AND CENTURY
          Alex.Keh .Product.Manager-Oracle

          That's an unusual error. There's no bugs reported with similar symptoms.

           

          What ODP.NET version are you using?

          Do you have a simple test case to reproduce?

          • 2. Re: ODP.NET DRIVER SWAPS YEAR AND CENTURY
            2730976

            HI Alex

             

            Thanks for the reply.

            Version:     v4.0.30319

             

             

            Untitled.png

             

            Oracle Table

             

            DESC                MY_TEST_TBL

            Name                Null Type

             

            MYDATE                DATE

             

             

            Here is my sample code

             

            private void button1_Click(object sender, EventArgs e)

                    {

                        string SQLCON = @"Data Source=(local);Initial Catalog=MyDataBase;Integrated Security=True";

                        string OraclCon = @"user id=myUserID;password=myPassword;data source=mydataSource";

                        string SQLCommand =@"SELECT CAST(GETDATE() AS DATE) as MyDate";

                        SqlDataReader dr = null;

             

             

                        SqlConnection SQLCon = new SqlConnection(SQLCON);

                        SqlCommand cmd = new SqlCommand(SQLCommand, SQLCon);

                        cmd.CommandTimeout = 600;

                        SQLCon.Open();

                        dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                       

                        if (dr.HasRows)

                        {

                            OracleBulkCopy objOBC = new OracleBulkCopy(OraclCon);

                            objOBC.DestinationTableName = "MY_TEST_TBL";

                            objOBC.BatchSize = 500000;

                            objOBC.BulkCopyTimeout = 10000;

                            objOBC.WriteToServer(dr);

                            objOBC.Close();

                            objOBC.Dispose();

             

             

                        }

             

             

                        dr.Close();

             

             

                    }

             

             

            After the above code runs

             

            Actual Result                 13/Aug/1420

            Expected Result:           13/Aug/2014

             

             

            Please See the image below

             

            UntitledOracle.png

             

             

             

            Thanks you so much

            • 3. Re: ODP.NET DRIVER SWAPS YEAR AND CENTURY
              2730976

              Hi Alex

               

              I would like to add one more bit to it that may help

               

              When i do Bulkcopy against Oracle XE on my local box it works fine. However, driver swaps century and year when Bulkcopy is used against instance running on Sun Solaris

               

              Thanks

              • 4. Re: ODP.NET DRIVER SWAPS YEAR AND CENTURY
                Alex.Keh .Product.Manager-Oracle

                I had a suspicion this was an endianness-related problem, or more precisely imperfect endian conversion.The last piece of info cinched it. XE generally runs on Intel hardware (little endian), which is different from Solaris (big endian).

                 

                This is very likely Bug 17785632, which has been fixed. The fix is not available in any current ODAC release, but will be in the next ODAC release. If you have access to Oracle's support site, the fix is available in the latest 11.2.0.4 patch or you can wait for the 12.1.0.2 DB client Windows release which should be available in the coming weeks.

                • 5. Re: ODP.NET DRIVER SWAPS YEAR AND CENTURY
                  2730976

                  Hi Alex

                   

                  Thanks for your reply. I have got the patch from Oracle's support site. The README.txt file that explains the installation instructions refers to two files  Oraclient11.dll and OraGeneric11.dll. I can only find Oraclient11.dll file in the patch folder and missing .OraGeneric11.dll file Also, looks to me that the patch instructions are for Linux/Unix. Is the same available for windows platform ?

                   

                   

                  step9.png

                   

                  Thanks

                  • 6. Re: ODP.NET DRIVER SWAPS YEAR AND CENTURY
                    Alex.Keh .Product.Manager-Oracle

                    That may be an oversight on the patch instructions. Try applying Oraclient11.dll by itself. The patch is for Windows. Was there an instruction in it that could only be done on Linux/Unix? Opatch will work on Windows.

                     

                    The other way to apply this fix is to apply the cumulative patch 11.2.0.4.2 or higher. That contains the same client fix, plus additional ones.