Inserting xml from url to table

What I need to do is to get the xml returned from a web service (complex type - dom style) and to insert it into a Database table trhough a plsql procedure. Then parsing the dom to get the single values (tag).
Anybody can help me?
Thank you
Davide

gave one example which worked for me in Oracle 8.1.7
I dont know whether u have seen my post ,,but here is the sample code again ,,which worked for me in an other manner.
CREATE OR REPLACE PACKAGE XRATESDLOAD AS
PROCEDURE XRATESDLOADP;
END XRATESDLOAD;
CREATE OR REPLACE PACKAGE BODY XRATESDLOAD AS
PROCEDURE XRATESDLOADP
IS
v_parser xmlparser.Parser;
v_doc xmldom.DOMDocument;
v_nl xmldom.DOMNodeList;
v_n xmldom.DOMNode;
TYPE tab_type IS TABLE OF CNA_XRATES_TEXT%ROWTYPE;
t_tab tab_type := tab_type();
BEGIN
-- Create a parser.
v_parser := xmlparser.newParser;
-- Parse the document and create a new DOM document.
xmlparser.parse(v_parser, 'http://www.xe.com/dfs/sample-gbp.xml');
v_doc := xmlparser.getDocument(v_parser);
-- Free resources associated with the Parser now it is no longer needed.
xmlparser.freeParser(v_parser);
-- Get a list of all the EMP nodes in the document using the XPATH syntax.
v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/xe-datafeed/currency');
dbms_output.put_line( 'Currency rates processed on '||to_char(sysdate, 'YYYY-MON-DD'));
-- Loop through the list and create a new record in a tble collection
-- for each EMP record.
FOR cur_emp IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
v_n := xmldom.item(v_nl, cur_emp);
t_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
t_tab(t_tab.last).CURRENCY_SYMBOL := xslprocessor.valueOf(v_n,'csymbol');
t_tab(t_tab.last).CURRENCY_NAME := xslprocessor.valueOf(v_n,'cname');
t_tab(t_tab.last).CURRENCY_RATE := xslprocessor.valueOf(v_n,'crate');
-- t_tab(t_tab.last).mgr := TO_NUMBER(xslprocessor.valueOf(v_n,'MGR'));
-- t_tab(t_tab.last).hiredate := TO_DATE(xslprocessor.valueOf(v_n,'HIREDATE'), 'DD-MON-YYYY');
-- t_tab(t_tab.last).sal := TO_NUMBER(xslprocessor.valueOf(v_n,'SAL'));
-- t_tab(t_tab.last).comm := TO_NUMBER(xslprocessor.valueOf(v_n,'COMM'));
-- t_tab(t_tab.last).deptno := TO_NUMBER(xslprocessor.valueOf(v_n,'DEPTNO'));
END LOOP;
-- Insert data into the real EMP table from the table collection.
-- Form better performance multiple collections should be used to allow
-- bulk binding using the FORALL construct but this would make the code
-- too long-winded for this example.
FOR cur_emp IN t_tab.first .. t_tab.last LOOP
INSERT INTO CNA_XRATES_TEXT
(CURRENCY_SYMBOL,
CURRENCY_NAME,
CURRENCY_RATE)
VALUES
(t_tab(cur_emp).CURRENCY_SYMBOL,
t_tab(cur_emp).CURRENCY_NAME,
t_tab(cur_emp).CURRENCY_RATE);
END LOOP;
dbms_output.put_line( 'Currency rates inserted into CNA_XRATES_TEXT table on '||to_char(sysdate));
COMMIT;
-- Free any resources associated with the document now it
-- is no longer needed.
xmldom.freeDocument(v_doc);
END XRATESDLOADP;
END XRATESDLOAD;
/

Similar Messages

  • Best way to fill CLOB with external XML from URL

    There seem to be a number of great tools available for pl/sql developers in the 8i DB environment and I am tryng to get a handle on them. So far I have worked with XSQL servlet (not PL/SQL), XML Parser and XSU.
    The problem I have is to fill a clob from an external xml file via a url and then make that clob available for DBMS_XMLSave to insert into DB. What is the best way to do this? I am thinking maybe I have to use utl_http or utl_tcp to fill the CLOB since I can't seem to find a method in the pl/sql XDK?
    XSU - can easily generate CLOB from a query but in this case it is not a query, it is XML from url
    XMlparser - can read in from a url using parse() but the document returned is a DOMDocument rather than CLOB.
    -quinn

    There seem to be a number of great tools available for pl/sql developers in the 8i DB environment and I am tryng to get a handle on them. So far I have worked with XSQL servlet (not PL/SQL), XML Parser and XSU.
    The problem I have is to fill a clob from an external xml file via a url and then make that clob available for DBMS_XMLSave to insert into DB. What is the best way to do this? I am thinking maybe I have to use utl_http or utl_tcp to fill the CLOB since I can't seem to find a method in the pl/sql XDK?
    XSU - can easily generate CLOB from a query but in this case it is not a query, it is XML from url
    XMlparser - can read in from a url using parse() but the document returned is a DOMDocument rather than CLOB.
    -quinn

  • Generate xml from non-relational table

    Hi
    I would like to create hierarchical xml from non-relational table as below, can anybody share some idea?
    I have tried the XMLAgg/XmlElement and could not get the desired result. Any help would be greately appreciated.
    create table testing
    ( super_cat varchar2(30)
    , normal_cat varchar2(30)
    , sub_cat varchar2(30)
    , detail varchar2(30));
    CREATE UNIQUE INDEX IDX_TESTING ON TESTING(SUPER_CAT,NORMAL_CAT,SUB_CAT);
    insert into testing values ('SUPER_A','NORMAL_A','SUB_A', 'DETAIL1');
    insert into testing values ('SUPER_A','NORMAL_A','SUB_B', 'DETAIL2');
    insert into testing values ('SUPER_A','NORMAL_B','SUB_A', 'DETAIL3');
    insert into testing values ('SUPER_A','NORMAL_B','SUB_B', 'DETAIL4');
    COMMIT;The result should be like :
    <Document>
    <SuperCategory>
    <SuperCategoryName>SUPER_A</SuperCategoryName>
    <NormalCategory>
    <NormalCategoryName>NORMAL_A</NormalCategoryName>
    <SubCategory>
    <SubCategoryName>SUB_A</SubCategoryName>
    <ResultDetail><Detail>DETAIL1</Detail></ResultDetail>
    </SubCategory>
    <SubCategory>
    <SubCategoryName>SUB_B</SubCategoryName>
    <ResultDetail><Detail>DETAIL2</Detail></ResultDetail>
    </SubCategory>
    </NormalCategory>
    <NormalCategory>
    <NormalCategoryName>NORMAL_B</NormalCategoryName>
    <SubCategory>
    <SubCategoryName>SUB_A</SubCategoryName>
    <ResultDetail><Detail>DETAIL3</Detail></ResultDetail>
    </SubCategory>
    <SubCategory>
    <SubCategoryName>SUB_B</SubCategoryName>
    <ResultDetail><Detail>DETAIL4</Detail></ResultDetail>
    </SubCategory>
    </NormalCategory>
    </SuperCategory>
    </Document>

    user563940 wrote:
    Hi
    I would like to create hierarchical xml from non-relational table as below, can anybody share some idea?
    I have tried the XMLAgg/XmlElement and could not get the desired result. Any help would be greately appreciated.I think you should be able to achieve this with the addition of XMLFOREST.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions244.htm#SQLRF06169

  • How to insert  data from different internal  table  into a data base table

    hi all,
             I want to insert a particular field in an internal table to a field in a data base table.Note that the fields in the internal table and database table are not of the same name since i need to insert data from different internal tables.can some one tell me how to do this?
    in short i want to do something like the foll:
    INSERT  INTO ZMIS_CODES-CODE VALUE '1'.
    *INSERT INTO ZMIS_CODES-COL1 VALUE DATA_MTD-AUFNR .(zmis_codes is the db table and data_mtd is the int.table)

    REPORT  ZINSERT.
    tables kna1.
    data: itab LIKE KNA1.
    data lv_kUNAG LIKE KNA1-KUNNR.
    lv_kuNAG =  '0000010223'.
    ITAB-kuNNR = lv_kuNAG.
    ITAB-name1 = 'XYZ'.
    INSERT INTO KNA1 VALUES ITAB.
    IF SY-SUBRC = 0.
    WRITE:/ 'SUCCESS'.
    ELSE.
    WRITE:/ 'FAILED'.
    ENDIF.
    Here lv_kunag is ref to kna1 kunnr passed in different name
    In internal table .
    Try and let me know if this logic dint work.

  • How to Insert data from notepad to Table

    Hi,
    I have one table with nodata.i need to insert data into table.but i have records in one notepad.if i enter manually
    like using insert statement it will take more time.
    Any one know insert data from notepad to table or i need sql script that will use for all the records.Here im using sqldeveloper.

    Hi dude,
    We can use below 2 types.
    1) Sql loader
    2) utl file
    SQL*Loader utility?
    One can load data into an Oracle database by using the sqlldr (sqlload on some platforms) utility. Invoke the utility without arguments to get a list of available parameters. Look at the following example:
    sqlldr username@server/password control=loader.ctl
    sqlldr username/password@server control=loader.ctlThis sample control file (loader.ctl) will load an external data file containing delimited data:
    load data
    infile 'c:\data\mydata.csv'
    into table emp
    fields terminated by "," optionally enclosed by '"'           
    ( empno, empname, sal, deptno )
    {code}
    The mydata.csv file may look like this:
    {code}
    10001,"Scott Tiger", 1000, 40
    10002,"Frank Naude", 500, 20
    {code}
    Optionally, you can work with tabulation delimited files by using one of the following syntaxes:
    {code}
    fields terminated by "\t"
    fields terminated by X'09'
    {code}
    Additionally, if your file was in Unicode, you could make the following addition.
    {code}
    load data
    CHARACTERSET UTF16
    infile 'c:\data\mydata.csv'
    into table emp
    fields terminated by "," optionally enclosed by '"'           
    ( empno, empname, sal, deptno )Another Sample control file with in-line data formatted as fix length records. The trick is to specify "*" as the name of the data file, and use BEGINDATA to start the data section in the control file:
    load data
    infile *
    replace
    into table departments
    (  dept     position (02:05) char(4),
        deptname position (08:27) char(20)
    begindata
    COSC  COMPUTER SCIENCE
    ENGL  ENGLISH LITERATURE
    MATH  MATHEMATICS
    POLY  POLITICAL SCIENCEPlease refer the below link.. it will useful for you.
    http://psoug.org/reference/sqlloader.html
    http://docs.oracle.com/cd/B10500_01/server.920/a96652/ch05.htm
    Regards,
    N.Senthil.

  • Insert XML data into oracle table

    I want to insert xml data returned by the VB code into oracle table.
    As a prequisite I have installed the XDK capabilities for Oracle by installing JServer & running
    SQL scripts catxsu.sql,xmlparserv2.jar,load.sql to load the XMLSQL Utility (DBMS_XMLQuery) into the database.
    I have also granted following privileges to the user.
    Grant users access to XMLParser and XMLDom packages:
         grant execute on xmldom to public;
         grant execute on xmlparser to public;
         create public synonym xmldom for sys.xmldom;
         create public synonym xmlparser for sys.xmlparser;
    But still i am not able to create procedure which will accept input parameter as an XML document coming from front end which in turn will insert that record into simple oracle table . I am using Oracle 8.1.7
    Thanks in advance

    Would you specify the database version?
    Since DBMS_XMLSave requires DOM, you normally need to divide the huge XML before insertion.

  • Logic for inserting values from Pl/sql table

    Hi I'm using Forms 6i and db 10.2.0.1.0
    I am reading an xml file using text_io, and extracting the contents to Pl/sql table.
    Suppose, the xml
    <?xml version="1.0" encoding="UTF-8" ?>
      <XML>
      <File name="S2_240463.201002170044.Z">
      <BookingEnvelope>
      <SenderID>KNPROD</SenderID>
      <ReceiverID>NVOCC</ReceiverID>
      <Password>TradingPartners</Password>
      </BookingEnvelope>
    </File>
    </XML>From this xml, i'm extracting contents to a table of records, say bk_arr, which look like
    Tag                             Val
    File name                     S2_240463.201002170044.Z
    SenderID                     KNPROD
    ReceiverID                   NVOCC
    Password                     TradingPartnersAnd now from this i've to insert into table, say bk_det .
    The tag may come in different order, sometimes some additional tags may also come in between,
    So i cannot access it sequentially and insert like
    Insert into bk_det(file,sndr,rcvr,pswd) values(bk_arr(1).val,bk_arr(2).val....)
    The tag name is constant ir for sender id, it will always be SenderID , not something like sndrid or sndid etc..
    So if i've to insert to senderid column, then i've to match the tag = SenderID, and take the value at that index in the array.
    How best i can do this?
    Thanks

    I am referring to how you are parsing the XML - as you can extract values from the XML by element name. And as the name is known, it's associated value can be inserted easily.
    Basic example:
    SQL> with XML_DATA as(
      2          select
      3                  xmltype(
      4  '<?xml version="1.0" encoding="UTF-8" ?>
      5  <XML>
      6          <File name="S2_240463.201002170044.Z">
      7                  <BookingEnvelope>
      8                          <SenderID>KNPROD</SenderID>
      9                          <ReceiverID>NVOCC</ReceiverID>
    10                          <Password>TradingPartners</Password>
    11                  </BookingEnvelope>
    12          </File>
    13  </XML>'         )       as XML_DOM
    14          from    dual
    15  )
    16  select
    17          extractValue( xml_dom, '/XML/File/@name' )                      as FILENAME,
    18          extractValue( xml_dom, '/XML/File/BookingEnvelope/SenderID' )   as SENDER_ID,
    19          extractValue( xml_dom, '/XML/File/BookingEnvelope/ReceiverID' ) as RECEIVER_ID,
    20          extractValue( xml_dom, '/XML/File/BookingEnvelope/Password' )   as PASSWORD
    21  from       xml_data
    22  /
    FILENAME                  SENDER_ID  RECEIVER_I PASSWORD
    S2_240463.201002170044.Z  KNPROD     NVOCC      TradingPartners
    SQL> Now this approach can be used as follows:
      create or replace procedure AddFile( xml varchar2 ) is
    begin
            insert into foo_files(
                    filename,
                    sender_id,
                    receiver_id,
                    password
            with XML_DATA as(
                    select
                            xmltype( xml ) as XML_DOM
                    from    dual
            select
                    extractValue( xml_dom, '/XML/File/@name' ),
                    extractValue( xml_dom, '/XML/File/BookingEnvelope/SenderID' ),
                    extractValue( xml_dom, '/XML/File/BookingEnvelope/ReceiverID' ),
                    extractValue( xml_dom, '/XML/File/BookingEnvelope/Password' )
            from    xml_data;
    end;
    /No need for a fantasy called PL/SQL "+tables+".

  • Inserting XML file  into a Table

    Hello,
    Can someone provide me with a sample code to load xml files into a table. Thanks a lot.
    Rajeesh

    Keeping my fingers crossed that this quote from "Building XML Oracle Applications" by Steve Muench (O'Reilly & Associates, 2000, ISBN 1-56592-691-9) falls into the "fair use" category, and that you want it in PL/SQL, here is a procedure:
    PROCEDURE insertXMLFile
    (dir VARCHAR2, file VARCHAR2, name VARCHAR2 := NULL) IS
    theBFile BFILE;
    theCLob CLOB;
    theDocName VARCHAR2(200) := NVL(name,file);
    BEGIN
    -- (1) Insert a new row into xml_documents with an empty CLOB, and
    -- (2) Retrieve the empty CLOB into a variable with RETURNING.INTO
    INSERT INTO stylesheets(docname,sheet) VALUES(theDocName,empty_clob( ))
    RETURNING sheet INTO theCLob;
    -- (3) Get a BFile handle to the external file
    theBFile := BFileName(dir,file);
    -- (4) Open the file
    dbms_lob.fileOpen(theBFile);
    -- (5) Copy the contents of the BFile into the empty CLOB
    dbms_lob.loadFromFile(dest_lob => theCLob, src_lob => theBFile, amount => dbms_lob.getLength(theBFile));
    -- (6) Close the file and commit
    dbms_lob.fileClose(theBFile);
    COMMIT;
    END;

  • Insert value from an interanal table to a table in word

    dear all
    can anyone tell me how to insert the data from  an internal table to the table created  in word, i can insert data  to the table of word by hard coding it,but finally the data has to come from  an internal table, im using OLE concept so code related to that will be highly appreciated. the functionality is the same as ALV gives to excel download,but just in my case it has to be in word,
    please help me i m in real need
    Regards
    Swarnali

    Hi
    If they have the same structure u can use a do cycle:
    LOOP AT  ITAB_NORMAL.
       DO.
         ASSIGN COMPONENT SY-INDEX OF STRUCTURE ITAB_NORMAL TO <VALUE_FROM>.
         IF SY-SUBRC NE 0. EXIT. ENDIF.   
         ASSIGN COMPONENT SY-INDEX OF STRUCTURE <DYN_WA> TO <VALUE_TO>.
        <VALUE_TO> = <VALUE_FROM>.
       ENDDO.
       APPEND <DYN_WA> TO <DYN_TABLE>.
    ENDLOOP.
    If the dynamic table has only certain fields of ITAB_NORMAL, I suppose u have an internal table with the fields of dynamic table (u should use it to generate the dynamic table) so u can loop it instead of DO/ENDO cycle
    LOOP AT  ITAB_NORMAL.
       LOOP AT ITAB_FIELD.
         ASSIGN COMPONENT ITAB_FIELD-FIELDNAME OF STRUCTURE ITAB_NORMAL TO <VALUE_FROM>.
         ASSIGN COMPONENT ITAB_FIELD-FIELDNAME OF STRUCTURE <DYN_WA> TO <VALUE_TO>.
        <VALUE_TO> = <VALUE_FROM>.
       ENDLOOP.
       APPEND <DYN_WA> TO <DYN_TABLE>.
    ENDLOOP.
    Anyway u can find out many solutions in SCN, there are many posts with your problem
    Max

  • Insert graphics from URL

    Hi,
    In a particular scenario i am trying to insert graphics in the smartform from the URL. Is it possible?
    If Yes, pl. let me know the steps.
    I know how to use graphics from the SE78 transaction, but not from URL
    The smartform is used in an e-mail if it helps.

    hi,
    Sorry it will not workk
    reward if useful
    regards,
    nazeer
    Message was edited by:
            nazeer shaik
    Message was edited by:
            nazeer shaik

  • How to insert data from file to table??

    I need to know that how can i insert data in multiple column through file. I can simply insert data in one column table but couldnt find out the way to put data in all column.
    My data store in a file
    ************************************************text.txt***************
    133, shailendra, nagina, 14/H, 45637, 9156729863
    **************************************************************my_data(table)**********
    trying to insert into below table...
    id, name, last_name, add, pin. mob
    Let me know if anything else needed..:)

    Hi Shailendra,
    Actually, in SQL Developer, you can open a connection to the target schema, right-click on the Tables node in the navigator tree view, select Import Data, then use the Data Import Wizard. It is extremely flexible. It looks like you have a comma separated variable file, so if you select Format: csv and Import Method: insert it will probably work just fine.
    To minimize the chance of errors during import, pick a preview limit value so the wizard can examine the size and data type of all columns in as many data rows as possible, then review the data type/size for each column in the next wizard page and override as necessary. For date columns it is also important to choose the appropriate format mask.
    Hope this helps,
    Gary
    SQL Developer Team

  • Error occured while inserting XML file data into table.

    Hello,
    I m trying to load xml data into table by following code.but getting below error
    Error at line 1
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00222: error received from SAX callback function
    ORA-06512: at "SYS.DBMS_XMLSTORE", line 78
    ORA-06512: at line 21
    DECLARE
      xmldoc   clob;
      insCtx   DBMS_XMLStore.ctxType;
      dname    varchar2(20) := 'MDIR';
      rows  number;
    BEGIN
        xmldoc := dbms_xslprocessor.read2clob(dname, 'try_xm3.xml');
        insCtx := DBMS_XMLStore.newContext('try1');
    dbms_output.put_line('1');
        DBMS_XMLStore.setRowTag(insCtx, 'cajas');
    rows := DBMS_XMLStore.insertXML(insCtx, xmlDoc);
    commit;
      dbms_output.put_line('INSERT DONE '||TO_CHAR(rows));
      DBMS_XMLStore.closeContext(insCtx);
    END;
    <?xml version="1.0" encoding="utf-8"?>
    <cajas xmlns="PBcion.Caja" fec="2011-03-02T14:20:14" codDeleg="093">
      <caj codPrev="80001223" fechaInicio="2011-03-02" fec="2011-09-02" couta="01" idPerio="1" caj="32"></caj>
    </cajas>can you please look into this?
    I m using oracle 10g

    SQL> create table try1
      2  (
      3  codPrev number,
      4  fechaInicio varchar2(25),
      5  fec varchar2(25),
      6  couta number,
      7  idPerio number,
      8  caj number
      9  );
    Table created
    SQL>
    SQL> insert into try1 (codprev, fechainicio, fec, couta, idperio, caj)
      2  select x.codprev, x.fechainicio, x.fec, x.couta, x.idperio, x.caj
      3  from xmltable(
      4         xmlnamespaces(default 'PBcion.Caja')
      5       , '/cajas/caj'
      6         passing xmltype(bfilename('TEST_DIR','try_xm3.xml'), nls_charset_id('AL32UTF8'))
      7         columns codPrev     number       path '@codPrev'
      8               , fechaInicio varchar2(25) path '@fechaInicio'
      9               , fec         varchar2(25) path '@fec'
    10               , couta       number       path '@couta'
    11               , idPerio     number       path '@idPerio'
    12               , caj         number       path '@caj'
    13       ) x
    14  ;
    1 row inserted
    SQL> select * from try1;
       CODPREV FECHAINICIO               FEC                            COUTA    IDPERIO        CAJ
      80001223 2011-03-02                2011-09-02                         1          1         32
    Since the two date attributes are coming in the W3C's xs:date format, you can directly define the corresponding columns as DATE and use a DATE projection in XMLTable :
    SQL> alter table try1 modify (fechainicio date);
    Table altered
    SQL> alter table try1 modify (fec date);
    Table altered
    SQL>
    SQL> insert into try1 (codprev, fechainicio, fec, couta, idperio, caj)
      2  select x.codprev, x.fechainicio, x.fec, x.couta, x.idperio, x.caj
      3  from xmltable(
      4         xmlnamespaces(default 'PBcion.Caja')
      5       , '/cajas/caj'
      6         passing xmltype(bfilename('TEST_DIR','try_xm3.xml'), nls_charset_id('AL32UTF8'))
      7         columns codPrev     number       path '@codPrev'
      8               , fechaInicio date         path '@fechaInicio'
      9               , fec         date         path '@fec'
    10               , couta       number       path '@couta'
    11               , idPerio     number       path '@idPerio'
    12               , caj         number       path '@caj'
    13       ) x
    14  ;
    1 row inserted
    SQL> select * from try1;
       CODPREV FECHAINICIO FEC              COUTA    IDPERIO        CAJ
      80001223 02/03/2011  02/09/2011           1          1         32

  • Insert records from a single table to two related tables

    DB - 10G
    OS - XP
    We have many thousands of comma delimited records that we want to insert into a normalised table structure.
    I have created a test dataset that can be found at the end of this post.
    I have csv records that look like this;
    donald, huey
    donald, dewey
    donald, louie
    And I want the data to be inserted into two separate table like this;
    table named PARENTS
    pk parent_name
    1  donald
    Table named CHILDRENS
    pk fk child_name
    1  1 huey
    1  2 dewey
    1  3 louie
    I constructed an insert statement that looks like this;
    INSERT ALL
      INTO parents (parent_id, parent_name) VALUES (parents_seq.nextval, parent_name)
      INTO children (children_id, parent_id, child_name) VALUES(children_seq.nextval, parents_seq.nextval, child_name )
    SELECT parent_name, child_name
      FROM sources;
    And this resulted in the following;
    Table named PARENTS
    pk child_name
    1  DONALD
    2  DONALD
    3  DONALD
    Table named PARENTS
    pk fk child_name
    1  1  HUEY
    2  2  DEWEY
    3  3  LOUIE
    Would anyone have any ideas on how I could accomplish this task?
    This is some example data;
    [code]
    DROP SEQUENCE parents_seq;
    DROP SEQUENCE sources_seq;
    DROP SEQUENCE children_seq;
    DROP TABLE sources;
    DROP TABLE children;
    DROP TABLE parents;
    CREATE SEQUENCE PARENTS_SEQ MINVALUE 1 MAXVALUE 1000000000000000000000000000 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE;
    CREATE TABLE PARENTS
    ( PARENT_ID      NUMBER(8) NOT NULL
    , PARENT_NAME    VARCHAR2 (50 CHAR) NOT NULL
    , CONSTRAINT     PARENTS_PK PRIMARY KEY (PARENT_ID)
    create or replace
    TRIGGER PARENTS_BI
    BEFORE
      INSERT OR UPDATE ON PARENTS
      FOR EACH ROW BEGIN
      IF INSERTING THEN
        IF :NEW.PARENT_ID IS NULL THEN
          SELECT PARENTS_SEQ.nextval INTO :NEW.PARENT_ID FROM dual;
        END IF;
      END IF;
    END;
    CREATE SEQUENCE SOURCES_SEQ MINVALUE 1 MAXVALUE 1000000000000000000000000000 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE;
    CREATE TABLE SOURCES
    ( SOURCE_ID      NUMBER(8) NOT NULL
    , PARENT_NAME    VARCHAR2 (50 CHAR) NOT NULL
    , CHILD_NAME    VARCHAR2 (50 CHAR) NOT NULL
    , CONSTRAINT     SOURCES_PK PRIMARY KEY (SOURCE_ID)
    create or replace
    TRIGGER SOURCES_BI
    BEFORE
      INSERT OR UPDATE ON SOURCES
      FOR EACH ROW BEGIN
      IF INSERTING THEN
        IF :NEW.SOURCE_ID IS NULL THEN
          SELECT SOURCES_SEQ.nextval INTO :NEW.SOURCE_ID FROM dual;
        END IF;
      END IF;
    END;
    INSERT INTO SOURCES (PARENT_NAME, CHILD_NAME) VALUES ('DONALD', 'HUEY');
    INSERT INTO SOURCES (PARENT_NAME, CHILD_NAME) VALUES ('DONALD', 'DEWEY');
    INSERT INTO SOURCES (PARENT_NAME, CHILD_NAME) VALUES ('DONALD', 'LOUIE');
    Commit;
    CREATE SEQUENCE CHILDREN_SEQ MINVALUE 1 MAXVALUE 1000000000000000000000000000 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE;
    PROMPT *** CREATE TABLE ***
    CREATE TABLE CHILDREN
    ( CHILDREN_ID    NUMBER NOT NULL
    , PARENT_ID      NUMBER NOT NULL
    , CHILD_NAME     VARCHAR2 (50 CHAR) NOT NULL
    , CONSTRAINT     CHILDREN_PK PRIMARY KEY (CHILDREN_ID)
    create or replace
    TRIGGER CHILDREN_BI
    BEFORE
      INSERT OR UPDATE ON CHILDREN
      FOR EACH ROW BEGIN
      IF INSERTING THEN
        IF :NEW.CHILDREN_ID IS NULL THEN
          SELECT CHILDREN_SEQ.nextval INTO :NEW.CHILDREN_ID FROM dual;
        END IF;
      END IF;
    END;
    [code]

    Looks like this is one way of achieving it:
    insert into parents (parent_name) select distinct parent_name from sources;
    select *
      from parents;
    PARENT_ID              PARENT_NAME                                       
    1                      DONALD
    insert into children (parent_id, child_name)
    select p.parent_id, s.child_name
      from sources s
      join parents p
        on (s.parent_name = p.parent_name);
    select *
      from children;
    CHILDREN_ID            PARENT_ID              CHILD_NAME                                        
    1                      1                      HUEY                                              
    2                      1                      DEWEY                                             
    3                      1                      LOUIE

  • Read xml from url

    Hello all,
    I am trying to get the data from this particular url : http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml
    I have no problem to parse it directly from a .xml or in xml chain. But I can't read the data directly from labview or even save the file at the url under a .xml.
    I already looked for the example like read http website and other but didn't succeed to adapt to my url.
    If any of you can help me
    thank you
    Solved!
    Go to Solution.

    Both of these seem to work just fine here in LV 2011:
    Note that the second one will require adding Datasocket support if you're building an installer and that the HTTP client VIs were only added around 2011.
    Try to take over the world!

  • Writing XML from memory to table

    Hi,
    I do NOT wish to write XML to a file in
    order store the XML into the database.
    I am creating the XML using the DOM API
    (addNode, etc.). Once created in memory,
    what strategy should I use to write the
    structure into (already created) tables?
    Regards,
    Diptendu

    Hi,
    I do NOT wish to write XML to a file in
    order store the XML into the database.
    I am creating the XML using the DOM API
    (addNode, etc.). Once created in memory,
    what strategy should I use to write the
    structure into (already created) tables?
    Regards,
    Diptendu

Maybe you are looking for

  • Post Upgrade to R2: Task Sequence Fails with 0x80070057

    one SCCM 2012 server for a while now (June/July of 2013) and have had no issues with OSD's and software deployments.  Today I decided to upgrade to R2 from CU3 and I thought the upgrade process went really well.  But after the upgrade I attempted to

  • Flickering Problem in external Facing Portal

    Hey     we had some problems developing our external facing portal mainly because of general flickering of the web page ( the page height is set to automatic and it causes the borders to adjust constantly to the current content height).   we have a p

  • Invoke or Invokel - error on argument mapping

    Hi... I'm trying to call a bpm method (witch receives 1 arg) from my jsp page, running from a Global Interactive, and i`m getting the error below The task could not be successfully executed. Reason: 'fuego.web.execution.exception.InternalForwardExcep

  • Airplay access through python script-win32com

    Hi, I am looking at automation to access  airplay accessories through iTunes. For example: When itunes running on windows discovers its Airplay accessory like Speaker, we will be able to see the Airplay Icon getting highlighted and we will be able to

  • Problem connecting iPhone to home hub

    Can anyone help me please I want to reconnect my iphone to my home hub after a full reset, I have followed all the help section instructions but keep getting the message 'can't connect'