Error trying to insert xml into Oracle table

Hi -
I am trying to (a)read a row from emp table and output the results in xml format
and (b) insert this row to another emp_new table (same structure as emp).
When I run it here is what I get:
OUTPUT IS:
<?xml verions='1.0'?>
<Employee>
<Emp num="1">
<EMPNO>7369</EMPNO>
<ENAME>Smith</ENAME>
<JOB>Clerk</JOB>
<MGR>7902</MGR>
<HIREDATE>12/7/1980</HIREDATE>
<SAL>800</SAL>
<DEPTNO>20</DEPTNO>
</Emp>
</Employee>
Exception in thread "main" oracle.xml.sql.OracleXMLSQLException:
No rows to modify -- the row enclosing tag is missing. Specify
the correct row enclosing tag.
etc...
The row enclosing tag is given by setRowTag("Emp").
What's wrong here? Any ideas?
PS: To Ambrose Padilla: Your response was helpful. Thank you.
Program
import java.sql.*;
import oracle.xml.sql.query.*;
import oracle.jdbc.driver.*;
import oracle.xml.sql.dml.*;
class testXML
public static void main(String[] args) throws SQLException
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//initialize a JDBC connection
Connecton conn = DriverManager.getConnection("jdbc:oracle:thin:mytest:1521:acme", "scott", "tiger");
//initialize the OracleXMLQuery
OracleXMLQuery qry =
new OracleXMLQuery(conn,"select * from emp where rownum < 2");
     // set the document name
     qry.setRowsetTag("Employee");
     // set the row element name
     qry.setRowTag("Emp");
     // get the XML result
     String xmlString = qry.getXMLString();
     // print result
     System.out.println(" OUPUT IS:\n"+xmlString);
     OracleXMLSave sav = new OracleXMLSave(conn,"emp_new");
     sav.insertXML(xmlString);
     sav.close();
}

Try inserting
sav.setRowTag("emp");
before calling insertXML.

Similar Messages

  • Insert data into oracle table from XML file

    I need to insert data into oracle table from XML file
    If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
    Thanks in advance

    The XML DB forum provides the best support for XML topics related to Oracle.
    Here's the FAQ on that forum:
    XML DB FAQ
    where there are plenty of examples of shredding XML into Oracle tables and such like. ;)

  • ORA-1013 when trying to insert data into the table

    Hi,
    While inserting record into a table, we are getting the following error:
    ORA-1013
    01013, 00000, "user requested cancel of current operation"
    I could not find any information in alert log also.
    We have a bitmap index on this table. However, we never got this error till now.
    Also i found that the tablespace who stores data has lot of space and tablespace which consists of the indexes is close to 90% full today ( i dont know what was the space available yesterday when there was error).
    I know that information i provided might be very less, but i gave as much information as i can provide.
    Can you please help me in trouble shooting this problem.
    Thank you
    Giridhar

    Sorry. i forgot to give version information
    Oracle version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    OS: SunOS 5.10
    we got it only once yesterday. only for one table. not for any other tables.
    Thanks aalap for your quick response.
    Giridhar

  • Read xml into oracle table

    Hi,
    How can I read an xml.file read in an oracle table (invoice varchar2(20), invoice_line number, ship_date date, country varchar2(100))?
    The xml looks like this:
    <?xml version="1.0" encoding="utf-8" ?>
    - <dataset xmlns="http://developer.cognos.com/schemas/xmldata/1/" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
    - <!--
    <dataset
    xmlns="http://developer.cognos.com/schemas/xmldata/1/"
    xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
    xs:schemaLocation="http://developer.cognos.com/schemas/xmldata/1/ xmldata.xsd"
    >
    -->
    - <metadata>
    <item name="Invoice #" type="xs:string" length="42" />
    <item name="Invoice Line" type="xs:string" length="10" />
    <item name="Ship Date" type="xs:date" />
    <item name="COUNTRY" type="xs:string" length="8" />
    </metadata>
    - <data>
    - <row>
    <value>26623</value>
    <value>0001</value>
    <value>2010-05-03</value>
    <value>USA</value>
    </row>
    - <row>
    <value>26624</value>
    <value>0001</value>
    <value>2010-05-03</value>
    <value>USA</value>
    </row>
    - <row>
    <value>26624</value>
    <value>0003</value>
    <value>2010-05-03</value>
    <value>USA</value>
    </row>
    - <row>
    <value>26625</value>
    <value>0001</value>
    <value>2010-05-03</value>
    <value>USA</value>
    </row>
    </data>
    </dataset>
    Thnx, Robbert

    Hi,
    Possible solutions will depend on your db version, which you didn't give.
    The following example assumes you're using 10gR2 :
    CREATE TABLE invoices (
    invoice varchar2(20),
    invoice_line number,
    ship_date date,
    country varchar2(100)
    DECLARE
    xmldoc xmltype := xmltype(
    '<?xml version="1.0" encoding="utf-8" ?>
    <dataset xmlns="http://developer.cognos.com/schemas/xmldata/1/" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
    <metadata>
    <item name="Invoice #" type="xs:string" length="42" />
    <item name="Invoice Line" type="xs:string" length="10" />
    <item name="Ship Date" type="xs:date" />
    <item name="COUNTRY" type="xs:string" length="8" />
    </metadata>
    <data>
    <row>
    <value>26623</value>
    <value>0001</value>
    <value>2010-05-03</value>
    <value>USA</value>
    </row>
    <row>
    <value>26624</value>
    <value>0001</value>
    <value>2010-05-03</value>
    <value>USA</value>
    </row>
    <row>
    <value>26624</value>
    <value>0003</value>
    <value>2010-05-03</value>
    <value>USA</value>
    </row>
    <row>
    <value>26625</value>
    <value>0001</value>
    <value>2010-05-03</value>
    <value>USA</value>
    </row>
    </data>
    </dataset>'
    BEGIN
      INSERT INTO invoices (invoice, invoice_line, ship_date, country)
      SELECT invoice, invoice_line, to_date(ship_date, 'YYYY-MM-DD'), country
      FROM XMLTable(
       XMLNamespaces(default 'http://developer.cognos.com/schemas/xmldata/1/'),
       '/dataset/data/row'
       passing xmldoc
       columns
         invoice      varchar2(20)  path 'value[1]',
         invoice_line number        path 'value[2]',
         ship_date    varchar2(10)  path 'value[3]',
         country      varchar2(100) path 'value[4]'
    END;
    /If your XML document resides outside the database, you may also access it directly through a DIRECTORY object :
    CREATE OR REPLACE DIRECTORY xmldir AS 'C:\oracle\invoices\xml';
    INSERT INTO invoices (invoice, invoice_line, ship_date, country)
    SELECT invoice, invoice_line, to_date(ship_date, 'YYYY-MM-DD'), country
    FROM XMLTable(
    XMLNamespaces(default 'http://developer.cognos.com/schemas/xmldata/1/'),
    '/dataset/data/row'
    passing xmltype( bfilename('XMLDIR', 'invoices.xml'), nls_charset_id('AL32UTF8') )
    columns
       invoice      varchar2(20)  path 'value[1]',
       invoice_line number        path 'value[2]',
       ship_date    varchar2(10)  path 'value[3]',
       country      varchar2(100) path 'value[4]'
    );Some docs about XMLTable and XML querying with Oracle :
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions228.htm#CIHGGHFB
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb_xquery.htm#ADXDB1700
    Edited by: odie_63 on 24 juin 2010 20:07

  • Trying to insert values into a table inserts the wrong values

    Hi, I'm sure this is quite simple but I don't know why it is happened (Spent about 2 hours debugging my program only to find the error is actually in the SQL insert statement not working properly hehe)
    I have a simple Payment table with the following columns:
    int - ID (primary key)
    int - Amount
    int - Paid
    varchar - Notes
    I try to place a new record into the table as follows:
    insert into payment values (1010,50,1,'Hello')
    but the ID i choose is not added to the record, rather the database assigns a ID instead automatically (it seems to add 1 to the last ID)
    On further inspection this happens for another of my tables too, however for another table, this does not happen and I can assign an ID as I would like.
    When creating my tables I thought I set them all up the same, however I guess not
    Does anyone know the problem?
    Thanks

    Hi,
    Are you are using this INSERT statement in any form??? if so, please check your pre-insert trigger.
    If not, then you may verify it by inserting it through iSQLPlus. If it doesn't insert your data, then check the database triggers associated with INSERT for your table.
    Regards,
    Zaaf

  • Exception while trying to insert data into Target Table

    Hi ,
    Im trying pick data from a table A which is in DB1 and trying to insert table B which is in DB2 .Below are the steps which I did.But im getting the exception
    *"Caused By: java.sql.SQLSyntaxErrorException: ORA-02019: connection description for remote database not found:"* .Can some one help me with this .
    Note : The DB that im using is Oracle 10g Express Edition and ODI studio is ODI 11.1.1.5.0
    1.Created a two Data Server -one for each Data base (DB1 and DB2)
    2.Created two Physical Schema under the respective Data Server
    3.Created two Logical Schema referring respective Physical Schema
    4.Created a two Models for each Logical schema and did Reverse Engineer
    5.Created an Interface , imported the Knowledge models and did the mapping between the Source and Target Data Source
    KM's used :
    Source data store-Staging Area-LKM Oracle to Oracle (DBLink)
    Target Properies-IKM Oracle Incremental Update
    I unchecked Stagin Area Different from Target .
    Thanks
    John

    Hi John,
    I think you need to create public database link then create public synonym
    After creating that, please check it from DB side it is working or not, then check from ODi end and go thru below URL hope this will helps you.
    https://forums.oracle.com/forums/thread.jspa?threadID=530074
    Thanks,
    Phani

  • Insert data into oracle table from XML script not working

    Hi,
    I wrote simple PL/SQL program to extract values from a XML file and disply all the employee names. But the first employee name repeating. Please can you tell me how to fix it.
    set serveroutput on size 2000;
    declare
    indoc VARCHAR2(2000);
    indomdoc dbms_xmldom.domdocument;
    innode dbms_xmldom.domnode;
    myParser dbms_xmlparser.Parser;
    l_nl dbms_xmldom.DOMNodeList;
    lv_value varchar2(30);
    l_n dbms_xmldom.DOMNode;
    begin
    indoc := '<emp> <name> Scott </name>
    <name> Tiger </name>
    </emp>';
    myParser := dbms_xmlparser.newParser;
    dbms_xmlparser.parseBuffer(myParser, indoc);
    indomdoc := dbms_xmlparser.getDocument(myParser);
    innode := dbms_xmldom.makeNode(indomdoc);
    l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(indomdoc),'/emp/name');
    dbms_output.put_line('Record count '||dbms_xmldom.getLength(l_nl));
    FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
    l_n := dbms_xmldom.item(l_nl, cur_emp);
    lv_value := dbms_xslprocessor.valueOf(l_n,'//name/text()');
    dbms_output.put_line('Emp Name : '||lv_value);
    END LOOP;
    end;
    /

    Based on an earlier example of mine from {message:id=2826611}
    This works in 10.2.x.x for sure. I can't recall (didn't look up) whether in 10.1 it allowed for going straight from a CLOB to a DOMDocument via newDomDocument.
    declare
       indoc    VARCHAR2(2000);
       indomdoc dbms_xmldom.domdocument;
       l_nl     dbms_xmldom.DOMNodeList;
       lv_value VARCHAR2(30);
       l_n      dbms_xmldom.DOMNode;
       l_xmltype   XMLTYPE;
       l_index     PLS_INTEGER;
    begin
       indoc := '<emp> <name> Scott </name>
       <name> Tiger </name>
       </emp>';
       indomdoc := dbms_xmldom.newDomDocument(indoc);
       l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(indomdoc),'/emp/name');
       dbms_output.put_line('Record count '||dbms_xmldom.getLength(l_nl));
       -- Method 1
       FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
          l_n := dbms_xmldom.item(l_nl, cur_emp);
          lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_n));
          dbms_output.put_line('Emp Name : '||lv_value);
       END LOOP;
       dbms_xmldom.freeDocument(indomdoc);
       -- Method 2
       dbms_output.new_line;
       l_xmltype := XMLTYPE(indoc);
       l_index := 1;
       WHILE l_xmltype.Existsnode('/emp/name[' || To_Char(l_index) || ']') > 0
       LOOP
          lv_value := l_xmltype.extract('/emp/name[' || To_Char(l_index) || ']/text()').getStringVal();
          dbms_output.put_line('Emp Name : '||lv_value);
          l_index := l_index + 1;
       END LOOP;
    end;

  • XML Data into oracle table

    Hi All,
    I am trying to insert data into oracle 9i temp tables using the following style. but getting error as
    ERROR at line 3
    ORA-00933 SQL command not properly ended
    Please assist me.
    INSERT INTO emp (empname,empno)
    SELECT *
    FROM XMLTABLE (
    '/EMP/CODE'
    PASSING xmltype (BFILENAME ('test_dir', 'emp.xml'), NLS_CHARSET_ID ('CHAR_CS'))
    COLUMNS empname VARCHAR (30) path 'empname',
    empno VARCHAR (30) path 'empno')
    MY emp.xml is
    <?xml version="1.0" encoding="AR8ISO8859P6"?>
    <EMP>
    <CODE>
    <EMPNAME>YALEXFBARK044</EMPNAME>
    <EMPNO>803926354086</EMPNO>
    </CODE>
    <CODE>
    <EMPNAME>YALEXFOLV0044</EMPNAME>
    <EMPNO>803926354109</EMPNO>
    </CODE>
    <CODE>
    <EMPNAME>YALEXFREDTT44</EMPNAME>
    <EMPNO>803926354093</EMPNO>
    </CODE>
    <EMP>

    >
    Oracle version: 8i - 9.0.x.x
    There was no option that I can recall or could find. All the parsing of XML that I've done in 8i was via the xmldom package.
    Oracle version: 9.2.x.x - 10.1.x.x
    This is were Oracle introduced extract, extractValue and TABLE(XMLSequence(extract())) for dealing with repeating nodes.
    Oracle version: 10.2.x.x
    Oracle introduced XMLTable as a replacement for the previous methods since it could handle all three methods for extracting data from XML. At that point, Oracle stopped enhancing extract/extractValue in terms of performance and focused on XMLTable. In 10.2.0.1 and .2, XMLTable was implemented via Java and in .3 it was moved into the kernel so performance from .3 onwards should be better than the older 9.2 / 10.1 methods. If not, feel free to open a ticket with Oracle support. Apparently Oracle also introduced XMLQuery as well but I've never heard of many using that in 10.2
    >
    from Methods to parse XML per Oracle version
    so use correct way for your oracle version

  • XML data into Oracle Tables. XML file on Application Server.Oracle Apps R12

    Hi All,
    My Database version : 11.2.0.2.0
    I have an XML file which needs to be loaded into the Database Tables. How ever i do not want to use the XMLTYPE as given below
    insert into test1 (
    SELECT PrcDate, PmtType, PmtStatus, PmtTypeCount, PmtTypeAmt
    FROM XMLTABLE(
    '/WFPaymentAck/RejectedDom1ACH'
    PASSING XMLTYPE( BFILENAME('ECX_UTL_LOG_DIR_OBJ','wf_test_xml.XML'), NLS_CHARSET_ID('UTF8') )
    COLUMNS
    PrcDate VARCHAR2(2000) PATH '@PrcDate' ,
    PmtType VARCHAR2(2000) PATH '@PmtType' ,
    PmtStatus VARCHAR2(100) PATH '@PmtStatus' ,
    PmtTypeCount VARCHAR2(100) PATH 'PmtTypeCount' ,
    PmtTypeAmt VARCHAR2(100) PATH 'PmtTypeAmt'
    Because this way the XML file needs to reside on the DB server.
    I am looking into other option of loading the XML file into a CLOB column of a table and reading it from that column.
    I did a couple of tests and feel that this way also the XML file has to reside on the Database Server itself. I am not sure if this is correct or if there is any problem with our TEST instance.
    ++Can anyone let me know if i need to have the XML file on the DB server instead of the Application server to load into a CLOB column of table ??++
    ++Or++
    ++Is there any other workaround for me to load XML into Oracle Tables, while having the XML file on Application Server.++
    Your immediate help is appreciated. I need to get past this ASAP.
    Thanks in Advance.
    VJ

    1) Are you asking me to create a folder on Database directory which points to a folder on the Apps server ?I suggest creating an Oracle directory object (a database object) pointing to a real location (folder) on Application server.
    we DONOT want a hand shake between the DB Server and the APPS server.I don't see where the problem is.
    I'm not familiar with Apps R12 but there's no doubt the two servers are already communicating, at least App server should be able to access the DB for the whole thing to run.
    As I said :
    One way or another, the data has to make its way to the database, there's no workaround to that.How do you imagine the data will end up in a database table if it doesn't come to the DB server?
    There's no magical method out there, both servers have to communicate at some point.
    About client-server approaches (client being here the App server), you can read about accessing the XML DB repository in the XML DB Developer's Guide : http://download.oracle.com/docs/cd/E11882_01/appdev.112/e23094/toc.htm
    Other option : SQL*Loader can load a CLOB, or an XMLType column too
    Edited by: odie_63 on 19 déc. 2011 20:22

  • Incorrect data value when insert into oracle table

    Would like to ask expert here, how could I insert data into oracle table where the value is 03 ? The case is like that,  the column was defined as varchar2(50) data type, and I have a csv file where the value is 03 but when load into oracle table the value become 3 instead of 03.

    user11432758 wrote:
    Would like to ask expert here, how could I insert data into oracle table where the value is 03 ? The case is like that,  the column was defined as varchar2(50) data type, and I have a csv file where the value is 03 but when load into oracle table the value become 3 instead of 03.
    implicit datatype conversion to NUMBER can result in leading zero to be eliminated.
    How do I ask a question on the forums?
    https://forums.oracle.com/message/9362002#9362002

  • Inserting Data into nested table

    I am exploring the differences between OBJECT & RECORD.
    As i am still in process of learning, I found that both are structures which basically groups elements of different datatypes or columns of different datatypes, one is used in SQL and other is used in PL/SQL, please correct me if I am wrong in my understanding.
    Below i am trying to insert data into an table of type object but i am unsuccessful can you please help.
    CREATE OR REPLACE type sam as OBJECT
    v1 NUMBER,
    v2 VARCHAR2(20 CHAR)
    ---Nested Table---
    create or replace type t_sam as table of sam;
    --Inserting data----
    insert into table(t_sam) values(sam(10,'Dsouza'));
    Error Message:
    Error starting at line 22 in command:
    insert into table(t_sam) values(sam(10,'Dsouza'))
    Error at Command Line:22 Column:13
    Error report:
    SQL Error: ORA-00903: invalid table name
    00903. 00000 -  "invalid table name"
    *Cause:   
    *Action:

    Ariean wrote:
    So only purpose of equivalent SQL types concept of nested tables is to use them as one of the data types while defining an actual table?
    Sort of - you can definitely use them for more than just "defining an actual table". (I'm fairly certain you could pass a nested table into a procedure, for example - try it, though - I'm not 100% sure on that - it just "makes sense". If you can define a type, you can use it, pass it around, whatever.).
    Ariean wrote:
    And that nested table could be a record in SQL or an Object in PLSQL or just simple datatype(number,varchar etc)?
    Nested tables are just like any other custom data type. You can create a nested table of other data types. You can create a custom data type of nested tables.
    It could get stupidly .. er, stupid O_0
    CREATE TYPE o_myobj1 AS object ( id1   number, cdate1  date );
    CREATE TYPE t_mytype1 AS table of o_myobj1;
    CREATE TYPE o_myobj2 AS object ( id2   number,  dumb  t_mytype1 );
    CREATE TYPE t_dumber AS table of o_myobj2;
    O_0
    Ok, my brain's starting to hurt - I hope you get the idea
    Ariean wrote:
    Secondly is my understanding correct about OBJECT & RECORD?
    I can't think of any benefit of describing it another way.

  • Map Excel worksheet into Oracle tables repository

    I am new to VB2005. I am working on VB code that can map(read) any table from excel worksheet and load it into Oracle table. Oracle table that I have are: 1)META_OBJECTTYPES(OBJECTTYPEID pk,OBJECTTYPENAME,OBJECTTYPEDESC, OBJECTMETATYPE,OBJECTDOMAIN).
    2) META_OBJECTS(OBJECTKEY PK,OBJECTTYPEID FK,OBJECTNAME,OBJECTDESC).
    3)META_OBJECTDEPENDENCIES(SRCOBJECTKEY FK, TGTOBJECTKEY FK,DEPENDENCYTYPE PK)
    4)META_OBJECTATTRIBUTES((OBJECTKEY FK, OBJECTATTRNAME PK,OBJECTATTRVALUE). NOTICE META_OBJECTTYPES IS PARENT TO META_OBJECTS AND META_OBJECTS IS PARENT TO (META_OBJECTDEPENDENCIES AND META_OBJECTATTRIBUTES) AND ALL PARENT HAS 1 TO MANY REALTIONSHIP TO CHILD TABLES. For example I have employee table in Excel worksheet that has two columns employee_id number, employee_name varchar2(50) I need my vb code map table name employee with its 2 columns into my 4 tables that I have in Oracle repository,
    My code so far just insert values into oracle tables in repository, but what is require is mapping table with contents into oracle tables.
    Imports System
    Imports System.Data ' VB.NET
    Imports Oracle.DataAccess.Client ' ODP.NET Oracle data provider
    Imports Excel = Microsoft.Office.Interop.Excel
    Public Class Form1
    'System.Data.OracleClient lets you access Oracle databases.
    Public con As System.Data.OracleClient.OracleConnection = New System.Data.OracleClient.OracleConnection() 'Oracle.DataAccess.Client.OracleConnection()
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim xlApp As Excel.Application
    Dim xlWorkBook As Excel.Workbook
    Dim xlWorkSheet As Excel.Worksheet
    Dim range As Excel.Range
    Dim rCnt As Integer
    Dim cCnt As Integer
    Dim Obj As Object
    xlApp = New Excel.ApplicationClass
    xlApp.Visible = True
    xlWorkBook = xlApp.Workbooks.Open("c:\employee.xls")
    xlWorkSheet = xlWorkBook.Worksheets("sheet1")
    range = xlWorkSheet.UsedRange
    For rCnt = 2 To range.Rows.Count
    For cCnt = 1 To range.Columns.Count
    Obj = CType(range.Cells(rCnt, cCnt), Excel.Range)
    MsgBox(Obj.value)
    Next
    Next
    xlWorkBook.Close()
    xlApp.Quit()
    releaseObject(xlApp)
    releaseObject(xlWorkBook)
    releaseObject(xlWorkSheet)
    End Sub
    Private Sub releaseObject(ByVal obj As Object)
    Try
    System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
    obj = Nothing
    Catch ex As Exception
    obj = Nothing
    Finally
    GC.Collect()
    End Try
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim daOracle As New OracleDataAdapter
    Dim InsertCommand As New OracleCommand
    daOracle.InsertCommand = New OracleCommand
    '1.Create connection object to Oracle database
    Dim con As OracleConnection = New OracleConnection()
    Try
    '2.Specify connection string
    con.ConnectionString = ("Data Source=dprod;User Id=smughrabi; Password=Sul9966")
    '3. Open the connection through ODP.NET
    con.Open()
    Dim cmd As OracleCommand = New OracleCommand
    cmd.Connection = con
    cmd.CommandType = CommandType.Text
    cmd.CommandText = "insert into meta_objecttypes values (4,'TABLE', 'TABLES','ERstudio','Demo')"
    cmd.ExecuteNonQuery()
    'You have to commit to be inserted into DB
    cmd.CommandText = "commit"
    cmd.ExecuteNonQuery()
    'Catch ex As Exception
    '4.display if any error occurs
    'MsgBox(ex.Message, Microsoft.VisualBasic.MsgBoxStyle.Exclamation, "OraScan")
    Finally
    ' Close and Dispose OracleConnection object
    con.Close()
    con.Dispose()
    End Try
    End Sub
    Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click
    Dim daOracle As New OracleDataAdapter
    Dim InsertCommand As New OracleCommand
    daOracle.InsertCommand = New OracleCommand
    '1.Create connection object to Oracle database
    Dim con As OracleConnection = New OracleConnection()
    Try
    If TableName.Text = "" Then
    MsgBox("Please enter the tablename", MsgBoxStyle.Exclamation, "OraScan")
    Exit Sub
    End If
    MsgBox(TableName.Text, MsgBoxStyle.Exclamation, "OraScan")
    '2.Specify connection string
    con.ConnectionString = ("Data Source=gema;User Id=dare; Password=rtae")
    '3. Open the connection through ODP.NET
    con.Open()
    Dim cmd As OracleCommand = New OracleCommand
    cmd.Connection = con
    cmd.CommandType = CommandType.Text
    cmd.CommandText = "select * from user_objects where object_name='" + UCase(TableName.Text) + "' and object_type='TABLE'"
    cmd.ExecuteNonQuery()
    'You have to commit to be inserted into DB
    'cmd.CommandText = "commit"
    'cmd.ExecuteNonQuery()
    MsgBox("Command executed successfully", MsgBoxStyle.Exclamation, "OraScan")
    'Catch ex As Exception
    '4.display if any error occurs
    'MsgBox(ex.Message, Microsoft.VisualBasic.MsgBoxStyle.Exclamation, "OraScan")
    Finally
    ' Close and Dispose OracleConnection object
    con.Close()
    con.Dispose()
    End Try
    End Sub
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TableName.TextChanged
    End Sub
    End Class

    Thanks Lyndon, what I need is map any table someone create in Excel worksheet to Oracle repository.For example to map Excel worksheet(employee)table with its 2 columns to oracle table META_OBJECTTYPES(OBJECTTYPEID pk,OBJECTTYPENAME,OBJECTTYPEDESC, OBJECTMETATYPE,OBJECTDOMAIN). In my case I have 2 objecttypes 1)table(employee) and 2nd columns:employee_id,employee_name
    --for inserting table info manually into DB:
    INSERT INTO META_OBJECTS
    (OBJECTKEY, OBJECTTYPEID,OBJECTNAME,OBJECTDESC)
    VALUES
    (META_OBJECTS_SEQ.NEXTVAL,
    4, --TABLE  
    'employee',--notice this is table name from Excel worksheet
    'Table to store employee info')
    --for inserting columns info:
    INSERT INTO META_OBJECTS
    (OBJECTKEY, OBJECTTYPEID,OBJECTNAME,OBJECTDESC)
    VALUES
    (META_OBJECTS_SEQ.NEXTVAL,5,'employee_id or name','employee column')
    notice above I insert manually Excel worksheet employee table with its two cols into oracle meta_objecttypes. What I want is VB to do this I mean if I go to Toad and erase what I insert in meta_objecttypes when I run vb, the program should map table employee with its 2 cols to Toad(DB). I hope it is clear now. Please refer to 1 st post for 3 other tables in DB

  • Map Excel worksheet into Oracle tables in repository

    I am new to VB2005. I am working on VB code that can map(read) any table from excel worksheet and load it into Oracle tables. Oracle tables that I have are: 1)META_OBJECTTYPES
    (OBJECTTYPEID pk,OBJECTTYPENAME,OBJECTTYPEDESC, OBJECTMETATYPE,OBJECTDOMAIN).
    2) META_OBJECTS(OBJECTKEY PK,OBJECTTYPEID FK,OBJECTNAME,OBJECTDESC).
    3)META_OBJECTDEPENDENCIES(SRCOBJECTKEY FK, TGTOBJECTKEY FK,DEPENDENCYTYPE PK)
    4)META_OBJECTATTRIBUTES
    (OBJECTKEY FK, OBJECTATTRNAME PK,OBJECTATTRVALUE).
    NOTICE META_OBJECTTYPES IS PARENT TO META_OBJECTS AND META_OBJECTS IS PARENT TO (META_OBJECTDEPENDENCIES AND META_OBJECTATTRIBUTES) AND ALL PARENT HAS 1 TO MANY REALTIONSHIP TO CHILD TABLES. For example, I have employee table in Excel worksheet that has two columns employee_id number, employee_name varchar2(50) I need my vb code map table name employee with its 2 columns into my 4 tables that I have in Oracle table repository,
    My code so far just insert values into oracle tables in repository, but what is require is mapping table with contents into oracle tables. If my expanation isn't clear plz let me know.
    Imports System
    Imports System.Data
    Imports Oracle.DataAccess.Client '
    Imports Excel = Microsoft.Office.Interop.Excel
    Public Class Form1
    'System.Data.OracleClient lets you access Oracle databases.
    Public con As System.Data.OracleClient.OracleConnection = NewSystem.Data.OracleClient.OracleConnection()
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim xlApp As Excel.Application
    Dim xlWorkBook As Excel.Workbook
    Dim xlWorkSheet As Excel.Worksheet
    Dim range As Excel.Range
    Dim rCnt As Integer
    Dim cCnt As Integer
    Dim Obj As Object
    xlApp = New Excel.ApplicationClass
    xlApp.Visible = True
    xlWorkBook = xlApp.Workbooks.Open("c:\employee.xls")
    xlWorkSheet = xlWorkBook.Worksheets("sheet1")
    range = xlWorkSheet.UsedRange
    For rCnt = 2 To range.Rows.Count 'rows in Excel start from row2
    For cCnt = 1 To range.Columns.Count 'column in Excel start from col1
    Obj = CType(range.Cells(rCnt, cCnt), Excel.Range)
    MsgBox(Obj.value)
    Next
    Next
    xlWorkBook.Close()
    xlApp.Quit()
    releaseObject(xlApp)
    releaseObject(xlWorkBook)
    releaseObject(xlWorkSheet)
    End Sub
    Private Sub releaseObject(ByVal obj As Object)
    Try
    System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
    obj = Nothing
    Catch ex As Exception
    obj = Nothing
    Finally
    GC.Collect()
    End Try
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim daOracle As New OracleDataAdapter
    Dim InsertCommand As New OracleCommand
    daOracle.InsertCommand = New OracleCommand
    '1.Create connection object to Oracle database
    Dim con As OracleConnection = New OracleConnection()
    Try
    '2.Specify connection string
    con.ConnectionString = ("Data Source=gema;User Id=dare; Password=rtae")
    '3. Open the connection through ODP.NET
    con.Open()
    Dim cmd As OracleCommand = New OracleCommand
    cmd.Connection = con
    cmd.CommandType = CommandType.Text
    cmd.CommandText = "insert into meta_objecttypes values (4,'TABLE', 'TABLES','ERstudio','Demo')"
    cmd.ExecuteNonQuery()
    'You have to commit to be inserted into DB
    cmd.CommandText = "commit"
    cmd.ExecuteNonQuery()
    Finally
    ' Close and Dispose OracleConnection object
    con.Close()
    con.Dispose()
    End Try
    End Sub
    Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click
    Dim daOracle As New OracleDataAdapter
    Dim InsertCommand As New OracleCommand
    daOracle.InsertCommand = New OracleCommand
    '1.Create connection object to Oracle database
    Dim con As OracleConnection = New OracleConnection()
    Try
    If TableName.Text = "" Then
    MsgBox("Please enter the tablename", MsgBoxStyle.Exclamation, "OraScan")
    Exit Sub
    End If
    MsgBox(TableName.Text, MsgBoxStyle.Exclamation, "OraScan")
    '2.Specify connection string
    con.ConnectionString = ("Data Source=gema;User Id=dare; Password=rtae")
    '3. Open the connection through ODP.NET
    con.Open()
    Dim cmd As OracleCommand = New OracleCommand
    cmd.Connection = con
    cmd.CommandType = CommandType.Text
    cmd.CommandText = "select * from user_objects where object_name='" + UCase(TableName.Text) + "' and object_type='TABLE'"
    cmd.ExecuteNonQuery()
    'You have to commit to be inserted into DB
    'cmd.CommandText = "commit"
    'cmd.ExecuteNonQuery()
    MsgBox("Command executed successfully", MsgBoxStyle.Exclamation, "OraScan")
    Finally
    ' Close and Dispose OracleConnection object
    con.Close()
    con.Dispose()
    End Try
    End Sub
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TableName.TextChanged
    End Sub
    End Class

    Don't know if this will help you or not, but I have some code that will read from and Excel spreadsheet and put the data into a DataSet (i'm sure something else could be used).
    string connectionString =
    @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\\testRead.xls;Excel 12.0;HDR=YES;IMEX=1";
    DbProviderFactory factory =
    DbProviderFactories.GetFactory("System.Data.OleDb");
    DbDataAdapter adapter = factory.CreateDataAdapter();
    DbCommand selectCommand = factory.CreateCommand();
    selectCommand.CommandText = "SELECT * FROM [dogs$]";
    DbConnection connection = factory.CreateConnection();
    connection.ConnectionString = connectionString;
    selectCommand.Connection = connection;
    adapter.SelectCommand = selectCommand;
    DataSet cities = new DataSet();
    adapter.Fill(cities);
    GridView1.DataSource = cities;
    GridView1.DataBind();
    Your provider might be different; the one above is for Office 2007. The [dogs$] in the selectCommand.commandText is the name of the worksheet in Excel.
    Hope this helps

  • Howto import XML into Excel table ?

    Hi,
    I asked this before in the Excel forums but received the suggestion that I ask here instead.  The question precis : How to ungrey the "Append new data to existing XML lists" checkbox so I can select it when importing XML data into an Excel
    spreadsheet.
    I have a local server which provides data in XML form and need to import successive reloads of the XML page into successive lines in an Excel spreadsheet.  I found the Excel help page entitled "How to use XML in Excel 2003" at http://office.microsoft.com/en-gb/excel-help/how-to-use-xml-in-excel-2003-HA001101964.aspx?CTT=1&origin=EC001022986
    which was useful in so far as permitting me to import the data using the XML Source task pane and mapping the elements I need from the XML source to columns in the spreadsheet.
    In order to append successive lines from the XML source page, as I understand it from the link I quoted,  I need to change the XML Map properties to "Append new data to existing XML lists".  However this checkbox is greyed out in the
    XML Map properties dialog box so I can't select it.
    Any ideas how I can achieve my aims here ?
    Thanks in advance,
    Mike

    Hi Mike,
    Thank you for contacting Office IT Pro General Discussions Services. 
    From your description, I understand that you tried to import XML into Excel table. You selected “Use the XML Source
    task pane” when opening the XML file, then you tried to check the option in the
    Map Properties window: "Append new data to existing XML lists". 
    However, this option is grayed out. If there is any misunderstanding, please feel free to let me know.
    I have checked the issue on my side but could not reproduce this issue. I suggest download the sample XML file as suggested on the page and test the
    issue again:
    http://www.microsoft.com/downloads/details.aspx?FamilyId=B4BD3283-AD0B-408D-9CE7-AB9C3537BBBB&displaylang=en
    If the problem does not occur with the sample XML file, this issue might occur as there are some problems with the XML you were using.
    If the problem also occurs in with the sample XML file, this issue might be related to some third-party software conflicts. I suggest checking this
    issue by starting Excel in the safe mode.
    Start the Office program in safe mode
    ==============
    1.      
    Click Start, point to All Programs, and then point to
    Microsoft Office.
    2.       
    Press and hold the CTRL key, and then click
    Microsoft Excel.
    If the problem does not occur in the safe mode, this issue might be related to some third-party add-ins in the Excel program, we can try to disable
    them. Normally, you could do the following to disable the conflict add-ins in your Excel program:
    Disable add-ins
    Click
    Tools > Options > 
    Add-in, click Go button in the Manage:
    Com-in Add.
    Check if there are any add-ins,
    clear the checkbox to disable them.
    Close the Office program and
    restart it.
    Add one check back each time to the list of Add-In,
    restart the Office program, and repeat the above procedure. Once the issue reappears again, we can determine which add-in causes this problem and then disable it.
    Please take your time to try the suggestions and let me know the results at your earliest convenience. If anything is unclear or if there is anything
    I can do for you, please feel free to let me know.
    Best Regards,
    Sally Tang

  • How to insert Serialised Object(XML DOM) into Oracle Table(as BLOB or CLOB)

    we need a urgent help. How can we insert and retrieve the XML Document DOM Object into Oracle Table.Actually we used BLOB for insert the DOM Object,its inserted finely but we have a problem in retrieving that object, we got error when v're retrieving. so could you anyone tell us what's this exact problem and how can we reslove this problem If anyone knows or used this kind operation, pls let us know immediately.
    Thanks in advance.

    Please repost your question in the appropriate XML forum, http://forums.oracle.com/forums/index.jsp?cat=51

Maybe you are looking for

  • How to display 0 Percentage in BEx Query Designer

    The BEx queries which I'm doing are ported to EP & client views all charts & data in portal only. I have a small requirement. My client requires to display 0% in the data output. Sample data is like Mon/Grade     A | B | C | D | E | F             " T

  • Hi can u pls help me

    0ECCS_C01 is not available as standard data source in RSA5. Could anyone help me how to handle this?

  • PDF file contents of word document using XSLT.

    Hi Public, I am creating pdf file through the XML, XSL and FOP. I want PDF file contents to display external file contents such as word document. I know for displaying image in PDF we use <fo:external-graphic> but what tag we should to display file c

  • How can I tell if I preordered an album

    I think that the subject states it all.  I thought I preordered an album, but I can't find a receipt for it nor can I find any word of it in my "Purchases".  Help?

  • Footnote function in FR V11.x

    Hi all we are using FR11.x, for creating hyperion reports, here i need some help regarding footnote using XBRL function 1) Requirement:- we are having a requirement where we need a to have a footnote(text) to be added in report, and that to be done u