OracleDataAdapter

Hello!
To simulate the native Oracle array-insert in the ODP .Net environment we use the OracleDataAdapter and the UpdateBatchSize property set to foe example 100. This shall (regarding to the documentation) minimize the number of roundtrips to the database. We found one problem though. Looking into the SQL trace we found that each parameter got a unique name even between rows. This means that Oracle needs to parse each SQL insert even though they are identical.
A 10000 row insert and UpdateBatchSize = 100 results in 100 roundtrips and 10000 parses of the "identical" insert. How is the OracleDataAdapter implemented?
BR
Jan

Hi Chee Pin,
Is "ultdba" an authenticated user for IIS and the connection can be opened successfully? (i.e. is conn.Open() okay?)
Sinclair

Similar Messages

  • OracleDataAdapter returning wrong number of columns

    Hello All,
    I have an issue of an oracle data adapter not returning all columns in my select statement. When I use code similar to below, the data adapter returns 2 columns per row instead of 5. And they are out of order (ie, DataRow(0) could be column 1 and DataRow(1) could be column 4 -- so I don't see which columns have been dropped without looking at the value).
    The database id XE on the local machine. The connection works fine. And the internal VS.NET PL/SQL debugger returns the query just fine.
    Some of the columns I'm trying to get are null -- in fact, most are. But they are changed during the program. So I still need them to show up in the dataset.
    BTW, I have had zero success getting OracleCommand.BindByName and OracleParameters to work, so I punted. Since I can get what I want out of readers and datasets, I can live without'em -- or can I?!?!
    I think my problem has something to do with handling null values. So I have tried the select statement with NVL wrapping the fields that could be null. But still no success.
    Any ideas?
    Table:
    account char(30) not null
    col_code as NUMBER(1,0) null ok
    columnIDontNeed as whatever null ok
    sum1 as char(1) null ok
    sum2 as char(1) null ok
    sum3 as char(1) null ok
    anotherColumnIDontNeed as whatever null ok
    Sample Code:
    dim oconn as New OracleConnection(conStrBldr.toString)
    Dim cmdLedger As OracleCommand = oconn.CreateCommand
    cmdLedger.BindByName = True ' seems to affect nothing! ever!
    cmdLedger.AddToStatementCache = False ' no noticable affect
    cmdLedger.CommandText = " SELECT account,col_code,sum1,sum2,sum3 "
    cmdLedger.CommandText &= "FROM gl.ledger "
    cmdLedger.CommandText &= "ORDER BY gl.ledger.account "
    cmdLedger.CommandType = CommandType.Text
    ' Create DataAdapter based on main Ledger SELECT
    Dim cmdLedgerDA As New OracleDataAdapter(cmdLedger)
    cmdLedgerDA.ReturnProviderSpecificTypes = True ' same results with False
    ' Create DataSet and Fill it.
    ' After this, we can now use this dataset
    ' to iterate through the GL ledger data.
    Dim cmdLedgerDS As New DataSet("GLBal")
    Try ' to fill dataset with Ledger SELECT
    ' fill dataset from OracleDataAdapter and the
    ' previously defined Oracle Command.
    cmdLedgerDA.Fill(cmdLedgerDS, "GL.LEDGER") ' tried with and without src
    Catch ex As OracleException
    ShowEx(ex)
    End Try ' to fill dataset with Ledger SELECT
    These are the typical test from within VB that I've run to check what was returned:
    console.writeline(cmdLedgerDS.Tables(0).Rows(0).ItemArray.Length)
    2
    dim row as DataRow = cmdLedgerDS.Tables(0).Rows(0)
    console.writeline(row(0).toString & row(1).toString & row(2).toString & row(3).toString & row(4).toString) ' EXCEPTION IS THROWN

    I cannot reproduce the error using basic code below. What is the specific exception you get?
    And BindByName is not necessary since you're not using bind variables
    Sub Main()
        Dim da As OracleDataAdapter
        Dim sqlstr As String
        Dim connstr As String
        Dim ds As DataSet
        Dim dr As DataRow
        Dim dc As DataColumn
        Try
            sqlstr = "select employee_id, first_name, last_name, null, salary "
            sqlstr &= "from employees where rownum < 10"
            connstr = "Data Source=xe;User ID=hr;Password=hr;"
            da = New OracleDataAdapter(sqlstr, New OracleConnection(connstr))
            ds = New DataSet("EmployeeDS")
            da.Fill(ds, "employees")
            For Each dc In ds.Tables("employees").Columns
                Console.Write(dc.ColumnName & " ")
            Next
            Console.WriteLine()
            For Each dr In ds.Tables("employees").Rows
                Console.WriteLine(dr(0).ToString & " " & _
                    dr(1).ToString & " " & dr(2).ToString & " " & _
                    dr(3).ToString & " " & dr(4).ToString)
            Next
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try
    End SubOutput should look like
    EMPLOYEE_ID FIRST_NAME LAST_NAME NULL SALARY
    100 Steven King  24000
    101 Neena Kochhar  17000
    102 Lex De Haan  17000
    103 Alexander Hunold  9000
    104 Bruce Ernst  6000
    105 David Austin  4800
    106 Valli Pataballa  4800
    107 Diana Lorentz  4200
    108 Nancy Greenberg  12000I am using VS2005, ODP 10.2.0.2.21 and OracleXE on remote machine.
    NH
    Message was edited by:
    nurhidayat

  • Oracle.DataAccess.Client.OracleDataAdapter exists in both v2 and v4

    Hi there,
    I am developing ASP Net application with ODP.NET 11.2.0.2.1 and VS 2010. The target framework is .Net framework 3.5 and I've explicitly Oracle.DataAccess reference to v.2, with
    <add assembly="Oracle.DataAccess, Version=2.112.2.0, Culture=neutral, PublicKeyToken=89B483F429C47342"/>
    , but when it compiled, it throw error
    The type 'Oracle.DataAccess.Client.OracleDataAdapter' exists in both
    'c:\WINDOWS\assembly\GAC_32\Oracle.DataAccess\2.112.2.0__89b483f429c47342\oracle.dataaccess.dll'
    and 'c:\WINDOWS\Microsoft.NET\assembly\GAC_32\Oracle.DataAccess\v4.0_4.112.2.0__89b483f429c47342\oracle.dataaccess.dll'     
    c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\esptweb\df172a69\e974c60e\App_Code.eoge0t0f.4.cs
    How can I fixed it?
    Thanks for the help.

    Did you try adding that reference using the Add Reference command in Visual Studio instead? I've never seen it behave like this before.
    There are two versions of the assembly, but it shouldn't be trying to load the .net 4 version if you have a reference to the .net 2 version and you're in a 2 (or 3.5) app.

  • Oracle.DataAccess.Client.OracleDataAdapter.Update not working

    Hi
    I am using the Oracle.DataAccess.Client.OracleDataAdapter from Oracle.DataAccess runtime version v4.0.30319. I set the SelectCommand and retrieve data from Oracle without any problems using the adapter to fill a datatable. I then use the DataTable.Clear method to remove all rows and fill it again from a different source using a different adapter. I use the Oracle.DataAccess.Client.OracleCommandBuilder to create the Insert and Update commands and finally I call the update command of the using the original adapter in order to update the Oracle database but nothing is updated.
    I examine the table row count at each stage and also display the table using a DataGridView on a form and all appears to be fine. No exception is thrown so I am stumped.
    I would be grateful for any suggestions as to what I am doing wrong.
    My environment is VS2010 Express
    Edited by: user1947494 on 04-Feb-2011 05:46

    Hi,
    Pretty tough without seeing any code. I really do not believe it has anything to do with the DataAdapter. What changed the specific row/rows after the second fill?
    But, as a guess, take a look at the DataTable - Rows - RowState. Run the below(or some variant) method just prior to your update.
    r,
    dennis
           public static DataTable GetDataTableChanges_Modified(DataSet dataSet, string dataTableName)
                if (dataSet.Tables[dataTableName].Rows.Count > 0)
                    DataTable dt = dataSet.Tables[dataTableName].Clone(); ;
                    int c = 0;
                    foreach (DataRow r in dataSet.Tables[dataTableName].Rows)
                        DataRowState state = r.RowState;
                        switch (state)
                            case DataRowState.Modified:
                                DataRow anewrow_dr = dt.NewRow();
                                anewrow_dr.ItemArray = r.ItemArray;
                                dt.Rows.Add(anewrow_dr);
                                c = c + 1;
                                break;
                            default:
                                break;
                    if (c > 0)
                        return dt;
                    else
                        return null;
                else
                    return null;
            }

  • OracleDataAdapter.Fill returns incorrect data for small numbers.

    Hi All,
    Recently we moved to Oracle client 11.1.0.7.20 with ODP.NET and instant client.
    And we encountered the following issue.
    When FetchSize of the command is set to any value that differs from default for some number fields with size <5 incorrect values are returned.
    I used the following code to reproduce the issue:
    var query = "SELECT * FROM RT ORDER BY ID";
    var connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=server)(PORT=1531)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=test)));User Id=user;Password=password;";
    var column = "IS_LEAF"; // data type is NUMBER(1, 0)
    using (var connection = new OracleConnection(connectionString))
    using (var cmd1 = connection.CreateCommand())
    using (var cmd2 = connection.CreateCommand())
    cmd1.CommandText = query;
    cmd2.CommandText = query;
    cmd2.FetchSize = 512*1024; // 512K
    var adapter1 = new OracleDataAdapter(cmd1);
    var table1 = new DataTable();
    adapter1.Fill(table1);
    var adapter2 = new OracleDataAdapter(cmd2);
    var table2 = new DataTable();
    adapter2.Fill(table2);
    for (int i = 0; i < table1.Rows.Count; i++)
    var row1 = table1.Rows;
    var row2 = table2.Rows[i];
    if (!object.Equals(row1[column], row2[column]))
    Console.WriteLine(string.Format("values don't match: {0}, {1}", row1[column], row2[column]));
    there are some ouput lines:
    values don't match: 0, 3328
    values don't match: 0, 3
    values don't match: 1, 3
    values don't match: 0, 318
    values don't match: 0, 264
    values don't match: 1, 10280
    values don't match: 1, 842
    values don't match: 1, 7184
    The column type is NUMBER(1, 0) and only values in the database are 1 or 0. So as you can see most of the values filled with custom fetch size are totally incorrect.
    We have several tables with small number fields and for some of them the issue reproduces but for others does not.
    And the issue doesn't appear:
    1. with Oracle client 11.1.0.6.20
    2. if I use data readers and compare values record by record.
    Our Oracle DB version is 10.2.0.4.
    Thanks,
    Maxim.

    For anyone that may find this at a later time, this behavior has now been corrected, and is available in 11107 Patch 31 and newer, available on My Oracle Support. Note that the "self tuning=false" did not work in all cases, so the only reliable solution is to get the patch.
    Greg

  • OracleDataAdapter with IN or IN-OUT parameters is not supported

    We are getting this message when we are trying to preview the data when creating an OracleDataAdapter with a SQL statement that has a parameter.
    What does this mean and is there a work-around for it as I'd really like to create a typed dataset from an SQL Statement.
    (If it means what I think it means, then I'm beginning to doubt the usefulness of using the Oracle Data Provider over MS version.)

    Hello,
    I have the same problem with Flat mode is not supported! at ... Characteristic.setHierarchy(Characteristic.java:335):
    Open, close, reload of the query does not help.
    Other SDN-thread "500 Internal Sever - Flat Mode is not Supported!" related to transaction RSRT.
    Execution of query via RSRT works, but the problem still persists in the BEx Web Analyzer.
    Could be related to a BEx Web Analyzer "bookmark" ("Personalize Web Application").
    I have not deleted any item. We use SAP BW 7.0 with a patch level approx. 09.2009.
    The "flat-mode" seems to be the  "BEx table mode".
    SAP hints do not seem to fit here:
    - 715820 BW 3.x Front-End Patch 14 (we use BW 7.0)
    - 874825 SAPBWNews for BW 3.x Front-End Support Package 19
    - 874827 SAPBWNews for BW 3.5 Front-End Patch 08 (we use BW 7.0)
    - 905229 update to SAPTableTree
    - 909824 Termination in flat mode when an object is deleted (old?)
    - 909827 Incorrect InfoProvider-dependent characteristic values
    - 910602 Condition includes too many characteristics (usage of deleted elements)
    - 915215 Termination when a query definition is changed (old? visibility of elements?)
    - 968273 Cache with flat files: Exception is not caught (does not apply to given error)
    Any new solutions?
    Best regards
    Thomas

  • OracleDataAdapter.Fill() slow while running in development enviornment

    I have found a potential issue with the OracleDataAapter where it runs slow during a Fill() execution under the following scenario:
    1) ODP.NET Version 10.1.0.400
    2) Visual Studio Framework Version 1.1
    3) Select command is a simple "SELECT * FROM <TABLE>" where some of the columns returned contain null values
    Under this scenario, the fill operation is slow and my CPU is pegged at 100% when running inside of the Visual Studio development environment. If I run it outside the development environment (CTRL-F5) it is not slow and runs fine.
    What I have found it the Oracle.DataAccess component is throwing an internal exception whenever it encounters a null value. The error can be obtained by changing Visual Studio to break into the debugger for all CLR exceptions (Debug Menu --> Exceptions). Here is the error being thrown:
    A first change exception of type 'System.InvalidCastException' occurred in oracle.dataaccess.dll
    Additional information: Column contains NULL data
    I can reproduce this problem with three lines of code:
    1. DataSet dataSet = new DataSet("SAMPLE");
    2. OracleDataAdapter adapter = new OracleDataAdapter("SELECT * FROM MYTABLE", "Data Source=MYDB.WORLD;User Id=my_user;Password=my_pwd");
    3. adapter.Fill(dataSet);
    I have seen other posts from people experiencing a similar problem, but not a resolution. Does anyone know if there is a resolution to this issue or is this a bug in the ODP library? Any help would be greatly appreciated.
    Thanks!
    Ross

    Well, I tried to open a TAR but don't seem to have ODP.NET anywhere in the product list. Interesting (perhaps) is that my test case runs in about 8 secs using the MS provider and something like 176 seconds using ODP.NET 10.1.0.4.0 and Oracle Client 10.1.0.4.0 on my low-end test machine. Here's my simple test case using the SH demo schema:
    using System;
    using System.Data;
    // using System.Data.OracleClient;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    namespace DataAdapterTest
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      class Class1
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
          int tickStart = 0;
          int tickEnd = 0;
          string constr = "User Id=sh; Password=sh; Pooling=false";
          OracleConnection con = new OracleConnection(constr);
          con.Open();
          DataSet ds = new DataSet();
          OracleDataAdapter da = new OracleDataAdapter("select * from customers", con);
          tickStart = Environment.TickCount;
          da.Fill(ds);
          tickEnd = Environment.TickCount;
          Console.WriteLine("Total Ticks: {0}", tickEnd - tickStart);
          da.Dispose();
          ds.Dispose();
          con.Dispose();
    }- Mark

  • OracleDataAdapter.FillSchema - mapping types in db to DataTable types

    OracleDataAdapter.FillSchema(table, Source) will configure a DataTable to match a table in database schema.
    How does FillSchema map types in the db schema to types associated with the DataTable columns?
    E.g. if the db column is NUMBER(2,0) the DataTable column appears to be System.Int16.
    How is this mapping done? Can it be configured?
    Basically I'm looking for documentation on the mapping from DB definitions, to
    Oracle.DataAccess.Client.OracleDbType
    and
    System.Data.DbType
    since the Output type of OracleParameter can have its DbType to insure that the values returned are .NET types.

    How does FillSchema map types in the db schema to types associated with the DataTable columns?
    How is this mapping done? Can it be configured?
    It's done internally as you might imagine and I'm not aware of any external configuration with one exception (see below).
    If you enable ODP trace you can get a flavor of what happens:
    Abridged copy of trace file output...
    TIME:2013/02/20-20:32:52:633 TID:1688  (ENTRY) OracleDataReader::GetSchemaTable()
    TIME:2013/02/20-20:32:52:643 TID:1688  (ENTRY) OracleDataReader::GetProviderSpecificFieldType()
    TIME:2013/02/20-20:32:52:643 TID:1688  (EXIT)  OracleDataReader::GetProviderSpecificFieldType()
    TIME:2013/02/20-20:32:52:643 TID:1688  (EXIT)  OracleDataReader::GetSchemaTable()
    TIME:2013/02/20-20:32:52:643 TID:1688  (ENTRY) OracleDataReader::GetName()
    TIME:2013/02/20-20:32:52:643 TID:1688  (EXIT)  OracleDataReader::GetName()
    Etc...The data adapter has a property called "ReturnProviderSpecificTypes" which does what its name suggests. It defaults to False but you can set to True (as I did for the above trace).
    As noted in the documentation, this property "Determines if the Fill method returns ODP.NET-specific values or .NET common language specification values".
    Keep in mind though that ODP Types are not the same as members of the OracleDbType enumeration.
    Regards,
    Mark

  • Error with query in OracleDataAdapter

    I have the following query:
    <code>SELECT FI.FACILITY_OID, FI.FACILITY_NUMBER , FI.FACILITY_NAME , FI.TYPE_CODE ,
    TC.DESCRIPTION AS TYPE_CODE_DESCRIPTION, FI.SUB_CATEGORY_CODE , SCC.NAME AS CATEGORY_CODE_DESCRIPTION,
    FI.HEADWALL_TYPE, FI.EXTERNAL_LENGTH , FI.EXTERNAL_WIDTH ,
    FI.INTERNAL_LENGTH , FI.INTERNAL_WIDTH , FI.FRONT_BARRICADED ,
    FI.INTERNAL_VOLUME , FI.FRAG_CONTAINED , FI.PORT_FACIL_EXCEPTION ,
    FI.REINFORCED_OPENINGS , FI.SINGLE_AIRCRAFT
    FROM FACILITY_INFO FI INNER JOIN TYPE_CODE TC ON FI.TYPE_CODE = TC.TYPE_CODE
    INNER JOIN SUB_CATEGORY_CODE SCC ON FI.SUB_CATEGORY_CODE = SCC.SUB_CATEGORY_CODE
    WHERE FI.TYPE_CODE IN ('ECM', 'AGM', 'REM', 'OSM', 'EOL')
    AND FI.INSTALLATION_ID = 1000 </code>
    The query works fine when I run it in the SQL command window of the OracleXE database web management tool, but when I try to use the query in the OracleDataAdapter.FillSchema method, I get the error:
    System.InvalidOperationException occurred
    Message="Syntax Error: Expecting ',' or 'WHERE' (etc.) after table alias."
    Source="System.Data.OracleClient"
    If I skip the FillSchema method and just call Adapter.Fill it works just fine - the query runs and the data is returned. So I would just drop the call to Adapter.FillSchema, but I suspect somebody put that call there for a reason and it will be missed it I just take it out. :)
    Anybody got any insight as to what's going on?

    Perhaps removing the ANSI syntax would be beneficial?
    SELECT
       FI.FACILITY_OID                        ,
       FI.FACILITY_NUMBER                     ,
       FI.FACILITY_NAME                       ,
       FI.TYPE_CODE                           ,
       TC.DESCRIPTION AS TYPE_CODE_DESCRIPTION,
       FI.SUB_CATEGORY_CODE                   ,
       SCC.NAME AS CATEGORY_CODE_DESCRIPTION  ,
       FI.HEADWALL_TYPE                       ,
       FI.EXTERNAL_LENGTH                     ,
       FI.EXTERNAL_WIDTH                      ,
       FI.INTERNAL_LENGTH                     ,
       FI.INTERNAL_WIDTH                      ,
       FI.FRONT_BARRICADED                    ,
       FI.INTERNAL_VOLUME                     ,
       FI.FRAG_CONTAINED                      ,
       FI.PORT_FACIL_EXCEPTION                ,
       FI.REINFORCED_OPENINGS                 ,
       FI.SINGLE_AIRCRAFT
    FROM
       FACILITY_INFO     FI
       TYPE_CODE         TC,
       SUB_CATEGORY_CODE SCC
    WHERE
       FI.TYPE_CODE       IN ('ECM', 'AGM', 'REM', 'OSM', 'EOL')
    AND
       FI.INSTALLATION_ID = 1000
    AND
       FI.TYPE_CODE = TC.TYPE_CODE
    AND
       FI.SUB_CATEGORY_CODE = SCC.SUB_CATEGORY_CODE  

  • Changes commited to the database only after I update OracledataAdapter twice

    Hi. I am using oracledataadapter to manage the data which is eventually displayed in winform datagridview (Visual Studio 2012)
    everything works fine , but I have to click "Save" buttin twice to see the changes in the database (Oracle express 11g)
    Can you please advice....
    Here is my code
    it is very simple
    1. Obtain connection
    2. Create dataadapter
    3. Create commands
    4. Fill the datatable and dataset
    public partial class Concordance : Form
            OracleDataAdapter setupAdapter;
            DataSet projDataset;
            OracleConnection conn;
            //binding sources
            BindingSource setupBindingSource = new BindingSource();
            DataTable setupTable;
            public Concordance()
                InitializeComponent();
                //load tables
                loadSetup();
            //setup table
            private void loadSetup()
                string oradb = ConfigurationManager.ConnectionStrings["OpenU"].ConnectionString;
                conn = new OracleConnection(oradb);
                try
                   // using (conn = new OracleConnection(oradb))
                    setupAdapter = new OracleDataAdapter("select * from ou_setup", conn);
                        OracleCommandBuilder builder = new OracleCommandBuilder(setupAdapter);
                        projDataset = new DataSet("Concordia");
                        setupTable = new DataTable("Setup");
                        projDataset.Tables.Add(setupTable);
                        setupAdapter.Fill(projDataset,"Setup");
                        //bind the gataGridView
                        this.setupGrid.DataSource = projDataset.Tables["Setup"];
                        this.setupBindingSource.DataSource = projDataset.Tables["Setup"];
                        this.setupNavigator.BindingSource = this.setupBindingSource;
                catch (Exception ex)
                    string error = ex.Message;
                    MessageBox.Show(error);
            private void saveSetupBtn_Click(object sender, EventArgs e)
               // only after sabe button clicked for the second time the changes are commited into the database
                this.setupAdapter.Update(projDataset.Tables["Setup"]);
                MessageBox.Show("saved");

    How are you reading in the object initially? The problem is likely that you are modifying an object from the session cache. When you then read in the object from the uow, it uses the object in the session cache as the back up. So there will not appear to be any changes to persist to the database.
    You will need to make a copy of the object for modification, or use the copy from the unitofwork to make the changes instead of working directly on the object in the session. Disabling the cache means there is no copy in the session cache to use as a back up, so the uow read has to build an object from the database.
    Best Regards,
    Chris

  • OracleDataAdapter returning incorrect schema information

    Hi everyone. I have a very reproducible case where the DataTable schema created by the OracleDataAdapter is incorrect. It is driving me crazy :-).
    ====================
    OracleConnection cnn = new OracleConnection("User ID=XXX;Password=XXX;Data Source=XXX");
    cnn.Open();
    string strQuery = "CREATE TABLE FOO (a INT, b INT)";
    OracleCommand cmdExec = new OracleCommand(strQuery, cnn);
    cmdExec.ExecuteNonQuery();
    OracleCommand cmdQuery = new OracleCommand("SELECT * FROM FOO", cnn);
    OracleDataAdapter adp = new OracleDataAdapter(cmdQuery);
    DataTable dtb = new DataTable();
    adp.Fill(dtb);
    Console.WriteLine("FOO has {0} columns.", dtb.Columns.Count);
    for (int i = 0; i < dtb.Columns.Count; i++)
    Console.WriteLine("{0}th column's name is {1}.", i, dtb.Columns[ i ].ColumnName);
    cmdExec.CommandText = "DROP TABLE FOO";
    cmdExec.ExecuteNonQuery();
    cmdExec.CommandText = "CREATE TABLE FOO (c INT, d INT, e INT)";
    cmdExec.ExecuteNonQuery();
    dtb = new DataTable();
    adp.Fill(dtb);
    Console.WriteLine("FOO has {0} columns.", dtb.Columns.Count);
    for (int i = 0; i < dtb.Columns.Count; i++)
    Console.WriteLine("{0}th column's name is {1}.", i, dtb.Columns[ i ].ColumnName);
    cnn.Close();
    Console.ReadLine();
    =============================
    The console output is:
    FOO has 2 columns.
    0th column's name is A
    1th column's name is B
    FOO has 2 columns.
    0th column's name is A
    1th column's name is B
    But it should be:
    FOO has 3 columns.
    0th column's name is C
    1th column's name is D
    2th column's name is E
    for the second iteration.
    What should I do?
    -- Matt

    I agree with the earlier comment stating '...that the caching is happening inside of the ODP layer rather than a lower layer such as OCI. It looks like the caching is occurring in the m_metaData member of the OracleCommand...'.
    It looks like all of the caching is indeed taking place in ODP. However there is in fact two levels of cache taking place in your particular example - at the OracleCommand level but also deep inside ODP.Net there is a static MetaData class which has a private member m_pooler that maintains a metadata cache on a per connection basis. Basically even if the OracleCommand object entry m_metaData is reset values still appear inside the internal pool and so there need to be removed too - this cache is indexed initially through a hash of the connection details and then statement text. This is why even a new OracleCommand object but with same statement text on same connection also returns incorrect information.
    Within the OracleReader implementations various calls are made to MetaData.Pooler.Get.. calls to retrieve cached information.
    I came across a similar problem (not identical) because we are using the 'alter session set current schema...' command and this causes some problems.
    Basically it appears a base assumption has been made that the definition of object will not change at runtime (which you can understand) but in my case it is possible that 'select * from emp' say could be execute from the same connection but relate to different objects because name resolution has been adjust using the 'alter session...' command which is a big problem.
    I have written some helper routines which enable the internal caches to be 'managed' although it uses some nasty reflection to accomplish this (using private members directly!). It work successfully in my case and I have done a quick change to your example code (added a single call) and it now works, i.e.
    cmdExec.CommandText = "CREATE TABLE FOO (c INT, d INT, e INT)";
    cmdExec.ExecuteNonQuery();
    OracleMetaDataRemover.Remove(cmdQuery, true);
    dtb = new DataTable();
    adp.Fill(dtb);
    If you use the Remove method above and change true to false you will still receive the problem because although the Command has been cleared the details still remain centrally.
    The code which accessed above I include below as is (coded for Oracle 10.1.0.3.01 ODP - it may work on other releases but note this could break in future). Ideally methods are required within ODP to allow cleardown/control of this.
    using System;
    using System.Reflection;
    using System.Collections;
    using Oracle.DataAccess.Client;
    namespace Oracle.DBUtilities
         /// <summary>
         /// Summary description for OracleMetaDataPoolerCleaner.
         /// </summary>
         public class OracleMetaDataPoolerCleaner
              private static string OracleAssemblyShortName = "Oracle.DataAccess";
              private static string OracleMDType = "Oracle.DataAccess.Client.MetaData";
              private static string OraclePoolerType = "Oracle.DataAccess.Client.Pooler";
              // Fast access pointer to internal hash of information
              private Hashtable PooledItems = null;
              private static OracleMetaDataPoolerCleaner _oracleMetaDataPoolerCleanerInstance = null;
              static readonly object _syncRoot = new object();
              private OracleMetaDataPoolerCleaner()
                   Assembly OracleDataAccess = null;
                   // Get hold of the Oracle Data Access assembly
                   Assembly[] LoadedAssemblyList = AppDomain.CurrentDomain.GetAssemblies();
                   for(int i=0; i<LoadedAssemblyList.Length && OracleDataAccess == null; i++)
                        Assembly LoadedAssembly = LoadedAssemblyList;
                        string[] AssemblyNameDetails = LoadedAssembly.FullName.Split(',');
                        if (AssemblyNameDetails[0] == OracleMetaDataPoolerCleaner.OracleAssemblyShortName)
                             OracleDataAccess = LoadedAssembly;
                   // Make sure located details
                   if (OracleDataAccess != null)
                        // Get access to the MetaData cache details
                        Type OracleMetaData = OracleDataAccess.GetType(OracleMetaDataPoolerCleaner.OracleMDType);
                        if (OracleMetaData != null)
                             // Retrieve static pool item
                             FieldInfo f_Pooler = OracleMetaData.GetField("m_pooler", BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.Static);
                             if (f_Pooler != null)
                                  // As we cannot get direct access to the object type assume it is OK
                                  object pa = f_Pooler.GetValue(null);
                                  if (pa != null)
                                       Type OraclePooler = OracleDataAccess.GetType(OracleMetaDataPoolerCleaner.OraclePoolerType);
                                       if (OraclePooler != null)
                                            FieldInfo f_Pools = OraclePooler.GetField("Pools", BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.Static);
                                            PooledItems = f_Pools.GetValue(pa) as Hashtable;
                                            if (PooledItems == null)
                                                 throw new InvalidOperationException("Unable to initialise metadata cache access...");
              public static OracleMetaDataPoolerCleaner Instance()
                   // Make single copy of this item ready for use
                   if (_oracleMetaDataPoolerCleanerInstance == null)
                        // Thread safe locking and initialisation - 'double-checked lock'
                        lock(_syncRoot)
                             if (_oracleMetaDataPoolerCleanerInstance == null)
                                  _oracleMetaDataPoolerCleanerInstance = new OracleMetaDataPoolerCleaner();
                   return _oracleMetaDataPoolerCleanerInstance;
              /// <summary>
              /// Using reflection the process determines the command text
              /// contents of the specified OracleCommand
              /// Note this could simply have been delegated through to the
              /// OracleConnection version using OCommand.Connection
              /// </summary>
              /// <param name="OCommand">OracleCommand object containing command to be retrieved</param>
              /// <returns>Command string located</returns>
              public static string CommandText(OracleCommand OCommand)
                   string OracleCommandCommandText = null;
                   // Using reflection get direct access to the 'private' member details..
                   Type TypeOracleCommand = OCommand.GetType();
                   FieldInfo FieldInfoCommandText = TypeOracleCommand.GetField("m_commandText", BindingFlags.NonPublic|BindingFlags.Instance);
                   if (FieldInfoCommandText != null)
                        OracleCommandCommandText = FieldInfoCommandText.GetValue(OCommand).ToString();
                   return OracleCommandCommandText;
              /// <summary>
              /// Using reflection the process determines the command text
              /// contents of the specified OracleCommand
              /// </summary>
              /// <param name="OReader">OracleDataReader object containing command to be retrieved</param>
              /// <returns>CommandString located</returns>
              public static string CommandText(OracleDataReader OReader)
                   string OracleDataReaderCommandText = null;
                   // Using reflection get direct access to the 'private' member details..
                   Type TypeOracleDataReader = OReader.GetType();
                   FieldInfo FieldInfoCommandText = TypeOracleDataReader.GetField("m_commandText", BindingFlags.NonPublic|BindingFlags.Instance);
                   if (FieldInfoCommandText != null)
                        OracleDataReaderCommandText = FieldInfoCommandText.GetValue(OReader).ToString();
                   return OracleDataReaderCommandText;
              /// <summary>
              /// Using reflection the process determines the hashvalue
              /// specified OracleConnection
              /// </summary>
              /// <param name="OConnection">OracleConnection for which the HashCode is to be retrieved</param>
              /// <returns>HashValue located or -1</returns>
              public static int ConnectionStringHashValue(OracleConnection OConnection)
                   int HashValue = -1;
                   // Using the Oracle Connection retrieve the hashvalue associated
                   // with this connection
                   if (OConnection != null)
                        Type TypeOracleConnection = OConnection.GetType();
                        FieldInfo f_ConStrHashCode = TypeOracleConnection.GetField("m_conStrHashCode", BindingFlags.NonPublic|BindingFlags.Instance);
                        if (f_ConStrHashCode != null)
                             HashValue = Int32.Parse(f_ConStrHashCode.GetValue(OConnection).ToString());
                   return HashValue;
              /// <summary>
              /// Using reflection the process determines the hashvalue
              /// specified OracleDataReader
              /// </summary>
              /// <param name="OReader">OracleDataReader for which the associated connection HashValue is to be located</param>
              /// <returns>HashValue located or -1</returns>
              public static int ConnectionStringHashValue(OracleDataReader OReader)
                   int HashValue = -1;
                   // Using reflection get direct access to the 'private' member details..
                   Type TypeOracleDataReader = OReader.GetType();
                   FieldInfo f_OraConnection = TypeOracleDataReader.GetField("m_connection", BindingFlags.NonPublic|BindingFlags.Instance);
                   // Ensure have access to a connection and retrieve has information
                   if (f_OraConnection != null)
                        OracleConnection ConnectionValue = f_OraConnection.GetValue(OReader) as OracleConnection;
                        HashValue = OracleMetaDataPoolerCleaner.ConnectionStringHashValue(ConnectionValue);
                   // Return the hashvalue information located
                   return HashValue;
              /// <summary>
              /// Using reflection the process determines the hashvalue
              /// specified OracleCommand
              /// Note this could simply have been delegated through to the
              /// OracleConnection version using OCommand.Connection
              /// </summary>
              /// <param name="OCommand">OracleCommand for which the associated connection HashValue is to be located</param>
              /// <returns>HashValue located or -1</returns>
              public static int ConnectionStringHashValue(OracleCommand OCommand)
                   int HashValue = -1;
                   // Using reflection get direct access to the 'private' member details..
                   Type TypeOracleCommand = OCommand.GetType();
                   FieldInfo f_OraConnection = TypeOracleCommand.GetField("m_connection", BindingFlags.NonPublic|BindingFlags.Instance);
                   // Ensure have access to a connection and retrieve has information
                   if (f_OraConnection != null)
                        OracleConnection ConnectionValue = f_OraConnection.GetValue(OCommand) as OracleConnection;
                        HashValue = OracleMetaDataPoolerCleaner.ConnectionStringHashValue(ConnectionValue);
                   // Return the hashvalue information located
                   return HashValue;
              /// <summary>
              /// Using the supplied OracleDataReader internal calls are made
              /// to determine the ConnectionHash and CommandText details which will
              /// then be used to remove the item
              /// </summary>
              /// <param name="OReader">OracleDataReader to be probed to obtain information</param>
              /// <returns>Indicates whether the item was actually removed from the cache or not</returns>
              public bool Remove(OracleDataReader OReader)
                   bool Removed = false;
                   // Lookup the ConnectionStringHashDetails
                   int HashValue = OracleMetaDataPoolerCleaner.ConnectionStringHashValue(OReader);
                   if (HashValue != -1)
                        // Lookup the command text and remove details
                        string CommandText = OracleMetaDataPoolerCleaner.CommandText(OReader);
                        // Attempt to remove from the cache
                        Removed = this.Remove(HashValue, CommandText);
                   return Removed;
              /// <summary>
              /// Using the supplied OracleCommand internal calls are made
              /// to delegate the call to the OracleConnection version
              /// </summary>
              /// <param name="OCommand">OracleCommand to be probed to obtain information</param>
              /// <returns>Indicates whether the item was actually removed from the cache or not</returns>
              public bool Remove(OracleCommand OCommand)
                   // Call into internal other routine
                   return this.Remove(OCommand.Connection, OCommand.CommandText);
              /// <summary>
              /// Using the supplied OracleConnection internal calls are made
              /// to determine the ConnectionHash and it uses CommandText details
              /// to remove the item
              /// </summary>
              /// <param name="OConnection">OracleConnection from which the cache object should be removed</param>
              /// <param name="CommandText">CommandText to be removed</param>
              /// <returns>Indicates whether the item was actually removed from the cache or not</returns>
              public bool Remove(OracleConnection OConnection, string CommandText)
                   bool Removed = false;
                   // Lookup the ConnectionStringHashDetails
                   int HashValue = OracleMetaDataPoolerCleaner.ConnectionStringHashValue(OConnection);
                   if (HashValue != -1)
                        // Attempt to remove from the cache
                        Removed = this.Remove(HashValue, CommandText);
                   return Removed;
              /// <summary>
              /// Routine actually removes the items from the cache if it exists
              /// </summary>
              /// <param name="ConnectionHashValue">ConnectionHash which is used to key into the Pooled items</param>
              /// <param name="CommandText">CommandText to be removed</param>
              /// <returns>Indicates whether the item was actually removed from the cache or not</returns>
              private bool Remove(int ConnectionHashValue, string CommandText)
                   bool Removed = true;
                   // Retrieve Pooled items for particular hash value
                   Hashtable PoolContents = PooledItems[ConnectionHashValue] as Hashtable;
                   // Remove item if it is contained
                   if (PoolContents.ContainsKey(CommandText))
                        PoolContents.Remove(CommandText);
                        Removed = true;
                   return Removed;
         /// <summary>
         /// Summary description for OracleMetaDataRemover.
         /// </summary>
         public class OracleMetaDataRemover
              private OracleMetaDataRemover()
              /// <summary>
              /// Routine which Removes MetaData associated with OracleCommand object
              /// </summary>
              /// <param name="OCommand">OracleCommand to have associated MetaData removed</param>
              /// <returns>Indicates whether the MetaData associated with the OracleCommand was reset</returns>
              public static bool Remove(OracleCommand OCommand)
                   bool Removed = false;
                   // Retrieve current MetaData values from OCommand
                   Type OracleCommandMetaData = OCommand.GetType();
                   FieldInfo f_metaData = OracleCommandMetaData.GetField("m_metaData", BindingFlags.NonPublic|BindingFlags.Instance);
                   if (f_metaData != null)
                        f_metaData.SetValue(OCommand, null);
                        Removed = true;
                   // Indicate Removed from OCommand object
                   return Removed;
              /// <summary>
              /// Routine which Removes MetaData associated with OracleCommand object
              /// and allows for the removal of information from the internal cache
              /// </summary>
              /// <param name="OCommand">OracleCommand to have associated MetaData removed</param>
              /// <param name="RemoveFromMetaDataPool">Whether item should be removed from the internal metadata pool too</param></param>
              /// <returns>Indicates whether the MetaData associated with the OracleCommand was reset</returns>
              public static bool Remove(OracleCommand OCommand, bool RemoveFromMetaDataPool)
                   bool Removed = false;
                   // Remove details from Command
                   Removed = Remove(OCommand);
                   if (Removed && RemoveFromMetaDataPool)
                        // Remove information form internal cache
                        Removed = OracleMetaDataPoolerCleaner.Instance().Remove(OCommand);
                   // Indicated Removed from OCommand and Internal MetaData collection
                   return Removed;

  • OracleDataAdapter.Fill() causes System.OverflowException on certain numbers

    This test shows how a value calculated in the database and stored in a column of type "number" (default scale/precision) causes an error upon retrieval using the OradleDataAdapter.Fill() method. The data type of the receiving column is irrelevant. The following example uses a decimal, but double, float, int, etc... all cause the same System.OverflowException error.
    Does anyone have a good suggestion of how to best handle this problem?
    I am using ODP.NET 9.2.0.4.0 (OraWin9204.exe) with Oracle9i (9.2.0.4.0) running both client and server on Windows 2000, using Visual Studio 2003.
    <code>
    /// <summary>
    /// The following test illustrates how a value that was calculated in the database
    /// causes an overflow error when retreiving it using the Oracle.DataAccess.Client
    /// </summary>
    public void ODP_CalculatedNumberIntoDecimalOverflowError()
         using (OracleConnection conn = new OracleConnection(CONNECT_STRING))
              conn.Open();
              try
                   using (IDbCommand createCmd = conn.CreateCommand())
                        createCmd.CommandText = "create table overflow_test (num number)";
                        createCmd.ExecuteNonQuery();
                   using (IDbCommand insertCmd = conn.CreateCommand())
                        insertCmd.CommandText = "insert into overflow_test (num) values (61 / 3)";
                        insertCmd.ExecuteNonQuery();
                   using (OracleCommand selectCmd = conn.CreateCommand())
                        selectCmd.CommandText = "select * from overflow_test";
                        DataTable overflowTest = new DataTable("overflow_test");
                        DataColumn num = new DataColumn("num", typeof (decimal));
                        overflowTest.Columns.Add(num);
                        OracleDataAdapter oda = new OracleDataAdapter(selectCmd);
                        oda.Fill(overflowTest);
                        int i = 0;
                        foreach (DataRow row in table.Rows)
                             Console.Out.Write("Row[{0}]:", i);
                             for (int j = 0; j < row.Table.Columns.Count; j++)
                                  Console.Out.Write(" {0}", row[j]);
                             Console.Out.WriteLine();
                             i++;
              finally
                   using (IDbCommand deleteCmd = conn.CreateCommand())
                        deleteCmd.CommandText = "drop table overflow_test";
                        deleteCmd.ExecuteNonQuery();
    </code>

    The problem is even worse: it also happens with aggregate functions like AVG
    CREATE Table Test (
    Value NUMBER(10,0)
    INSERT INTO Test VALUES (20);
    INSERT INTO Test VALUES (20);
    INSERT INTO Test VALUES (21)
    SELECT AVG(Value) from Test
    Adding the SafeMapping means we have to adjust our code to expect string values instead of decimals
    The other workaround: (use ROUND or TRUNC) means we have to adjust all Sql statements!
    Please solve this bug in the ODP.NET client, i.e. create a way to get normal .NET native type values into a DataSet. (oda.TruncateDecimals = true?)

  • Question about OracleDataAdapter

    Hi,
    I'm using ODP.NET
    I'm executing a Package which returns a REF CURSOR, the amount of columns is over 100. I execute the query in SQL and it returns the data ok, but when executing package with ODP.NET i have an error that says arithmetic overflow.
    code I use below:
    OracleDataAdapter da = new OracleDataAdapter(Data);
    da.Fill(dt);
    I simplify the query to bring up 27 columns and ODP.NET worked.
    Can somebody tell me if there is a type of restriction with the columns or rows return using OracleDataAdapter ?
    thanks for the help you can give me.

    Hi,
    I presume there are some NUMBER field in the result set. Oracle NUMBER datatype can store floating point number up to 22 bytes, while .net double can only store 8 bytes (64 bit), that why you get an arithmetic overflow.
    try rounding all number before returning the result set, this should solve your problem.
    Cheers,
    NH

  • Working with OracleDataAdapter

    Hi,( new to .NET Environment )
    1) When tables are dragged from oracle explorer of vs2005, it creates adapter,connection and a dataset( for a single table).
    if another table dragged another dataset created and so on.
    Is there is any way to have all the tables in the same dataset, like what provided in the data source configuration wizard by MS.
    2) is there is any problem for the following.
    using .net 2.102.2.10 (oracle.dataaccess.client) created the oracledataadapter,commandbuilder , but created the dataset using the data source configuration wizard (system.data.oracleclient).
    I am getting error in my system like. referenced assembly targets different processor than the application.
    Reply Please.
    Mohan Raj K.

    thanks for reply.
    It is just my point of view. thats all. that is why I am asking.
    the Feature / Concept of the dataset is to accomodate any(kind)/all tables in a single dataset.
    coz, if i want to handle a form of about 6 to 7 tables, the controls/adapter comes around 30(unnecessay Maintenance).
    and Regarding my First Query?
    is there any problem if the adapter,commandbuilders are created with oracle.dataaccess.client and working with datatables that are created with system.data.oracleclient ?
    Will it, create any update Problems?.
    Reply.
    Thanks for the Reponse
    Mohan Raj K.

  • OracleDataAdapter.fill cause ArgumentOutOfRangeException

    We have data that is saved by a Oracle Forms application. This data includes a Date field for the time the data was last saved. If I try to read this data into a DataTable, a call to the OracleDataAdapter.Fill method causes an ArgumentOutOfRangeException.
    "Year, Month, and Day parameters describe an un-representable DateTime."
    at System.DateTime.DateToTicks(Int32 year, Int32 month, Int32 day)
    at System.DateTime..ctor(Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second)
    at Oracle.DataAccess.Client.OracleDataReader.GetValue(Object[] values)
    Looking at the data with Oracle Developer I noticed something interesting. The raw view of the date saved from the Forms app differs from a date saved from Developer or a .NET app.
    select dump(savedate), to_char(savedate, 'ddmmyyyy hh24miss') from xxxTable;
    Typ=12 Len=7: 80,86,1,9,17,13,4          09012014 161203
    Typ=12 Len=7: 120,114,1,9,17,13,4     09012014 161203
    The former is a date saved from the Forms app. The latter is a date saved from Developer/.NET app. Yet Developer seems to know how to format both. Is this a bug in the database, or in the OracleDataAdapter or in Oracle Forms, or in our code?
    Oracle.DataAccess.dll     v.2.102.2.20

    Well, turns out the erroneous date have a negative year, i.e. BC. I referred this to our Oracle Forms devs.
    The way Oracle stores date internally is like this.
    Jan. 1st, 2014 16:12:03
    Typ=12 Len=7: 120,114,1,9,17,13,4     09012014 161203
    120 - 100 = 20
    114 - 100 = 14
    ==> year 2014
    1 ==> January
    9 ==> 1st
    17 - 1 = 16
    13 - 1 = 12
    4 - 1 = 03
    If you do the same to the erroneous date, the year is negative.
    80 - 100 = -20
    86 - 100 = -14
    ==> -2014 or 2014 BC
    I consider it a bit of a faux-pas that Oracle Developer's default formatting doesn't use SYYYY (S being the negative/positive sign).
    EDIT.
    You can also change the date formatting in Oracle Developer from Tools > Preferences > Database > NLS.

Maybe you are looking for

  • How can I use an old Mac as a monitor for a Mini?

    My sister has an old iMac, circa 2006, that can no longer be updated, so she's considering getting a Mini and somehow using the old iMac as a monitor. Is this possible? I found a very old post that referred to ScreenRecycler, but this appears to be a

  • Can I use variables in mxml tags?

    I want to control a lot of details in a layout.  I need to use variables to do this.  Of course I can use AS.  Is there a way to do it in the MXML tags?  See the code below.  I can do the "myLine.x = lineX" in AS.  But is there something like:  x="{l

  • CLFMAS Basic type (IDOC)

    Hi, BD10 is used to send material master and message type MATMAS can be used for it. Like that i want to send data related to basic type CLFMAS01 and message type CLFMAS which transaction should i use. Rgds, Ganesh

  • Help.. help.. HP Mini 1000.. reset bios!!! CNU9257483

    help.. help.. HP Mini 1000.. reset bios!!![edited Serial Number by Moderator] Thank all>>>>> This question was solved. View Solution.

  • J2ME write into a file

    hello, I succeed to read a file which at the address "http://localhost:8004/hello.txt" but I don't succeed to write into a file which the same address How write into a file, in a midlet?