Updating data from grid to Oracle database.

Hi
I am having some trouble updating data in a grid back to the Database. I have provided an example below. I am using the ODP.NET protocol.
The query in the proc is a simple SELECT * FROM xxxx. There are no joins (outer or inner) at all. The table xxxx has a primary key. The proc is used to fill a grid. It does this correctly by returning data to a DataTable which is then used as the data source for a grid. Then, when I make a change in the grid and press the update button, the application trys to use the da.UpdateCommand = cmdBuilder.GetUpdateCommand() statement and gets the error
"Dynamic SQL generation failed. No key information found".
Note I have tried to get around this problem by adding a key to the DataTable ... no luck.
I also tried da.MissingSchemaAction = MissingSchemaAction.AddWithKey ... no luck.
I have also tried da.FillSchema(dt, SchemaType.Mapped); ... no luck.
What am I doing wrong? ... is there a better way?
public partial class Form1 : Form
private OracleConnection a_Conn = null;
private DataTable dt = null;
private OracleDataAdapter da = null;
private OracleCommand cmd = null;
public Form1()
InitializeComponent();
private void Form1_Load(object sender, EventArgs e)
a_Conn = new OracleConnection();
a_Conn.ConnectionString = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
a_Conn.Open();
dt = new DataTable();
//SPS_TEST is a stored proc that takes no param and simply returns a dataset
cmd = new OracleCommand("SPS_TEST", a_Conn);
cmd.CommandType = CommandType.StoredProcedure;
//setup ref cursor (needed for oracle)
cmd.Parameters.Add("Cursor", OracleDbType.RefCursor, ParameterDirection.Output);
da = new OracleDataAdapter(cmd);
//da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
DataColumn[] keys = new DataColumn[1];
keys[0] = dt.Columns["Name of Column with primary key in Table I have queried"];
dt.PrimaryKey = keys;
da.Fill(dt);
//grid is successfully filled at this point
fpSpread1.DataSource = dt;
private void btnUpdate_Click(object sender, EventArgs e)
OracleCommandBuilder cmdBuilder = new OracleCommandBuilder(da);
da.UpdateCommand = cmdBuilder.GetUpdateCommand();
dt.AcceptChanges();
da.Update(dt);
Rob
Edited by: user8803094 on 10-Mar-2010 19:38
Edited by: user8803094 on 10-Mar-2010 20:56

To the best of my knowledge, and I may be wrong here, a ref cursor does not contain any base table information. It simply contains metadata about what's in the cursor itself. The commandbuilder doesnt know what table the data came from , if it even came from an actual db table at all. As such, it's not possible for the commandbuilder to know how to generate an update statement.
You CAN update a dataset you created from a refcursor, but you have to supply your own UpdateCommand in the case, rather than using a commandbuilder.
If your ref cursor is simply a select from a table, it would probably be pretty easy to (at design time) get and note the updatecommand and parameters from a select * from the table, and then use that for the updatecommand of the dataset filled from a refcursor, as the metadata should match up. Probably not something you'd want to do on the fly though.
Hope it helps,
Corrections/comments welcome.
Greg

Similar Messages

  • How can i convert data from DBF to oracle database 10g?

    Sir,
    How can i convert data from DBF to oracle database 10g?

    I assume you at least know how to dump the contents of foxpro dbf file into CSV format.
    Regarding SQL*Loader, hope this demo makes it a bit clear to you...
    http://www.princeton.edu/~storacle/sqlloader_demo.shtml
    I agree that it is an old web page (references Oracle 8.0.5) but basics remain the same.
    If it is still unclear to you after referring above link, then get an Oracle consultant.

  • Can someone tell me how to delta update data from db like oracle?

    Hi gurus:
         as the title,can someone tell me how to delta update data from db like oracle?
    and can someone give me some link about the detail of delta update?
        thanks very much.
    chan

    Hi,
    Check help links
    Data Transfer with DB Connect
    http://help.sap.com/saphelp_nw04/helpdata/en/58/54f9c1562d104c9465dabd816f3f24/frameset.htm
    http://www.bwexpert.com/downloads/DBConnectMakingDELTAABAPCode.doc
    Delta Concept
    http://help.sap.com/saphelp_nw04/helpdata/en/84/81eb588fc211d4b2c90050da4c74dc/frameset.htm
    Thanks

  • Import/insert data from XML into Oracle database tables?

    Hi. (I am using JDeveloper 10.1.3.3.0 and Oracle 10g)
    I have been able to export the data from one of my database tables by using a View Object and .writeXML.
    Now, I want to take an xml file that is formatted in the same way as what is spit out by the writeXML and put that info in my database table. I followed online examples and have tried using .readXML like so:
    Element element = XMLDoc.getDocumentElement();
    vo.readXML(element, -1);
    I know it is sort of working, because at first I got an error message that one of the required attributes was missing. So, I added that attribute to my xml file and ran my code. No errors. But, I checked my database, and the new records were not added.
    Is there something I have done wrong? Or is there perhaps something I left out? I also noticed there were several versions of readXML like readFromXML. Which one should I use and how?
    Thanks.

    KUBA, I changed my code to match your example:
    DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    File xmlFile = new File("C:/myfilehere.xml");
    Document doc = db.parse(xmlFile);
    Element element = doc.getDocumentElement();
    vo.readXML(element, -1);
    vo.getDBTransaction().commit();
    I still get no errors, but my database table has no new records.
    Any ideas why?
    Thanks.

  • Copy data from mysql to oracle database help?

    Im an sql newb and trying to understand how I can automatically copy data from one dtabase to another systems database on the same server.
    We have two differnt applications, but both share customer information, but one is on a win server, while the other is on oracle.
    Each time a customer contacts us via online chat (win server, mysql), we want to copy their entire chat transcript into our CRM's (oracle) customer account. So the folks that use the CRM can see the past chat histories. I hope this makes sense.
    Where can i look to get started on this?
    Thanks

    You could look at Heterogeneous Services (see the forum here Heterogeneous Connectivity but if you want to push data from mysql to oracle you might be better looking at it from the mssql side. I don't know what they offer.
    It might be simpler to do it at the client end. ie cut and paste from the online chat application into a new utility which inserts into the oracle database.
    Incidentally, this forum is specifically for the SQLDeveloper tool. You might get more general help in the "database - general" or "sql and pl/sql" forums

  • Error in CLOB datatype for transfering data from Excel to Oracle database

    Am using excel sheet as source and Oracle as target Database.
    For all tables the operations works smoothly except for tables containing CLOB datatype.
    Initially i have used SQL Developer to transfer some data into excell sheets, now i want to transfer those file's data into another Oracle Database.
    What other options do i have?
    Is excel not the right tool to transfer CLOB datatypes?

    well,
    I couldn't suggest an excel to do it...
    You can go from Oracle to Oracle with the PL/SQL IKM. It works fine.
    Does it help you?

  • How to extract data from essbase to oracle database incrementally?

    I have to extract data from essbase to an oracle database table incrementally using informatica , can anyone tell me how to do it or give me some tips. I have been thinking about it for a whole day but have no ideas.
    I cannot do the delete & insert method because this oracle database table is a interface table that has to deliver the data to Oracle ESB tables.
    Thanks in advance....

    Hi,
    Have you read through :-
    Oracle Data Integrator Adapter for Hyperion Essbase Getting Started - http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/odiess_getting_started.pdf
    Oracle Data Integrator Adapter for Hyperion Essbase User's Guide - http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/odiess_users.pdf
    If you have read them and are still have a problem at what stage are you having the issues?
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • How to get the updated data from a third party database in office 365 list

    Hello - I am trying to access a third party software database to create a dynamic Dashboard in SharePoint, and my approach is :-  
    Sync the 3rd part database in list (should get sync in list whenever new data is added to the 3rd party database) or if possible syc the data from CSV file to sharepoint list.
    I need to get that data into Giant chart or Dashboard
    any help will be highly appreciated.
    Thank you!

    There are many options available in SharePoint Online office 365 for connecting to External data e.g. external lists, Business Data Web Parts etc. Please check these urls for more details -
    Introduction
    to external data
    Use
    external data in workbooks in SharePoint Online
    Overview of Business Connectivity Services in SharePoint 2013
    Thanks
    Ganesh Jat [My Blog |
    LinkedIn | Twitter ]
    Please click 'Mark As Answer' if a post solves your problem or 'Vote As Helpful' if it was useful.

  • Transfer of data from excel to Oracle database? Please reply as soon as possible

    Hello:
    How can I transfer data from MS Excel into Oracle8/8i database.
    Please give me step by step instructions or necessary code required
    Thank you
    Dinakar

    Save the excel data in .CSV file format, then use SqlLoader.
    Your SqlLoader control file might look as follows
    LOAD DATA
    INFILE c:\test_data.csv
    APPEND
    INTO TABLE emp
    FIELDS TERMINATED BY ","
    (fld1, fld2, fld3, ...)

  • Need to fatch the data from sqlserver to Oracle DATABASE ;not migration

    Hello,
    What is the easiest method to insert/refresh data into Oracle Tables from SQLSERVER 2005 table.Do I need ODBC connection and how it works in the PL/SQL to create the connection and fetch the data from sqlserver.
    Thanks,
    Sarabmann

    I need to fetch from ORACLE back-end ,for example I want to install the mechanism at the back-end server where if I write stored procedure and call this link which enable me to fetch the data from sqlserver.
    Environment:- Linux as OS
    Oracle 10G as a Database

  • How to store data from xml in oracle database

    Hello All
    Could anyone tell me ways of storing XML in Oracle and whats the best one in terms of performance issues.
    any URL to this q/s would be great.
    thanks
    kedar

    Ben,
    The following link as some information regarding DOM API and XSQL.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:2923508047773696280::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:17309127931717
    For XML DB, you may want to create an XMLSchema and build a table off the schema definition. Then use WEBDAV to load the xml into a folder (ie object table) Once the xml is in the database you could build a view for a relational look at the data.
    Example from XMLDB Techical White Paper doc.
    create or replace view PURCHASEORDER_MASTER_VIEW
    (reference, requestor, userid, costcenter,...)
    as select extractValue(Value(p),'/PurchaseOrder/Reference'),
    extractValue(value(p),'/PurchaseOrder/Requestor'),
    extractValue(value(p),'/PurchaseOrder/User'),
    extractValue(value(p),'/PurchaseOrder/CostCenter'),...
    from PURCHASEORDER p

  • How to delete data before insert in oracle database

    Hi friends,
    I have one scenario.I want to send data from sap to Oracle database.Befor i am inserting data in database table,i want to clean/delete all the records in the table .This interface will run twice in a day.Can any body help me.
    SAP-PI-JDBC
    Thanks
    Ravi

    Hi Puneet,
    As per u r suggestions,i am using stored procedure.But i am getting following error.
    Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. MASTERXXXXXX' (structure 'Statement'): java.sql.SQLException: ERROR: Invalid XML document format for stored procedure: 'type="<SQL-type>"' attribute is missing for element 'NAME' (Setting a SQL-type (e.g. INTEGER, CHAR, DATE etc.) is mandatory !)'
    I have define below structure.Please check the structure and guide me.
    <Statement
            Action   attribute  required
            Table 
    Access  
            Empname   string
            Empid         string
            date            date
              Type     attribute   required
    EXECUTE----
    >Action
    Table----
    >MASTERXXXXXX
    Type----
    >char
    Please check the above structure andguide me to changes if any requires.
    Thanks
    Ravi

  • Export database from BerkeleyDB to Oracle Database

    Hi,
    Within the framework of some projetc, for creating reports, I need to export data from BerkeleyDB to Oracle database.
    How can I do it ?

    Hello,
    One way to export data from a Berkeley DB database into an Oracle DB table
    is to use the OCI interface on the Oracle DB side and the C API on the Berkeley DB side. If you have access to "My Oracle Support" an example can be found in Note 797537.1.
    Thanks,
    Sandra

  • Moving data from .xls spreadsheet to database table

    Hi,
    Does any one know a script or the procedure to move data from an .xls spreadsheet to a database table?
    Thanks,
    Ranjana

    Hi,
    check this out.. !!
    Import data from Excel to Oracle Database and
    Added link From Ask Tom.. your requirement you would be satisfied.. I supppose.. !!
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:908428873069
    - Pavan Kumar N

  • Replication of data from LDAP to Oracle 10g Database

    Hi All,
    in our application we are using Oracle Identity manager, and Oracle 10g database.
    we are storing the user,profile and privilages in LDAP and due to some reason we have to create user table in the 10g database.
    this user table values and LDAP user table values must be same.
    here the source is LDAP and destination is Oracle.
    so is there any way we can synchoronize or replicate the data from LDAP to 10g database?
    since oracle identity manager is integrated with LDAP,
    i feeel this must be possible.
    but really dont know how?
    kindly suggest me.
    and if any examples available please let me know, i will be very greatful to you.
    Thanks in advance

    Check out thread How synchronize OID user to a table?
    The title of the thread is: How synchronize OID user to a table?

Maybe you are looking for

  • Converting AVI DV to QuickTime DV. Do you lose quality?

    I posted this in the FCE forum but wonder if any DV gurus in here might have a definite answer. I have a some dv streams in avi format that have been captured using Sony Vegas from DV tapes. The files suffixed .avi will not open in Quicktime, but I f

  • Recover from Windows 7 back to Vista

    I have installed Windows 7 over my Vista implementation. Now I want to recover to Vista again and want to make use of my recovery partition on the harddisk. However, the Lenovo button in combination with F11 does not work and always logs me on to Win

  • Problem in Proxy to FIle senario.

    Hi , I have a simple proxy to file senario, which is working fine. The problem is that i have to put one more file on the FTP server which has some text of 7 characters that denotes that the Proxy was successful. This second file should only be creat

  • Select and move text on 80 pages

    I want to move all headlines in my 80 pages long InDesign (CS4) document about 10mm downwards. Is there a way I can do that with some clicks? All titles have the same paragraph styles.

  • How to provide signal lights in ALV output

    Hi Experts, i have one requirement. i am developing one object oriented alv report based on standard report(RFREISCN).i have one requirement in the output provide signal lights(RED(for inactive) AND YELLOW(for account assignment locks)) and to provid