XML data in the table using sql/plsql

Hi experts,

Could you please help with the following requirement. I have the tags xml (.xml on a server file) below. I need to access this file and read the XML and insert into the db table using sql and plsql. Is it possible with the cdata below? And there is a nested this table.

Could someone please guide me if you have a sample code file and xml.

<? XML version = "1.0" encoding = "UTF-8"? >

< generation_date > <! [CDATA [17/11/2015]] > < / generation_date >

< generated_by > <! [CDATA [Admin Admin]] > < / generated_by >

< year > <! [CDATA [2015]] > < / year >

< month > <! [CDATA [01]] > < / month >

< author >

< author > <! [CDATA [user author]] > < / author > < author_initial > <! [CDATA [user]] > < / author_firstname > < author_country > <! [CDATA [author]] > < / author_lastname >

< author_email > <! [CDATA [[email protected]]] > < / author_email >

< author_data_01 > <! [CDATA []] > < / author_data_01 >

< author_data_02 > <! [CDATA []] > < / author_data_02 >

< items >

< article_item >

< article_id > <! [CDATA [123456]] > < / article_id >

< publication > <! [CDATA [Al Bayan]] > < / publication >

< section > <! [CDATA [Local]] > < / section >

< issue_date > <! [CDATA [11/11/2015]] > < / issue_date >

< page > <! [CDATA [2]] > < / print this page >

< article_title > <! [CDATA [title.]] > < / article_title > < number_of_words > <! [CDATA [165]] > < / number_of_words >

< original_price > <! [CDATA [200]] > < / original_price >

< original_price_currency > <! [CDATA [DEA]] > < / original_price_currency >

< price > <! [CDATA [250]] > < / price >

< price_currency > <! [CDATA [DEA]] > < / price_currency >

< / article_item >

< / articles >

< total_amount > <! [CDATA [250]] > < / total_amount >

< total_amount_currency > <! [CDATA [DEA]] > < / total_amount_currency >

< / author >

< / xml >

Thanks in advance,

Suman

XMLTABLE using...

SQL > ed
A written file afiedt.buf

1 with t (xml) as (select xmltype ('))
2
3
4
5
6
7
8
9
10
11
[[12 [email protected]]] >
13
14
15
16
17
18
19


20
21
22
23
24
25
26
27
28
29
30
31
32
33 ") of the double)"
34-

35 end of sample data
36-
37 - assumptions:
(38 - a) XML may have several tags
(39 - b) each may contain more
40-
41 select x.gen_by, x.gen_date, x.mn, x.yr
42, y.author, y.auth_fn, y.auth_ln, y.auth_cnt, y.auth_em, y.auth_d1, y.auth_d2

43, z.id, z.pub, z.sec, z.iss_dt, z.pg, z.art_ttl, z.num_wrds, z.oprice, z.ocurr, z.price, z.curr
44 t
45, xmltable ('/ authxml')
from $ 46 t.xml
path of 47 columns gen_date varchar2 (10) '. / generation_date'
48, path of varchar2 (15) of gen_by '. / generated_by'
49, path of varchar2 (4) year '. "/ year"
50 varchar2 (2) mn road '. "/ month"
51, path of xmltype authors '.'
52                 ) x
53, xmltable ('/ authxml/authors ')
from $ 54 x.authors
author of 55 path of varchar2 columns (15) '. / author'
56, path of varchar2 (10) of auth_fn '. / author_firstname'
57, path of varchar2 (10) of auth_ln '. / author_lastname'
58 road of VARCHAR2 (3) auth_cnt '. / author_country'
59 road of varchar2 (20) of auth_em '. / author_email'
60 road of varchar2 (5) of auth_d1 '. / author_data_01'
61, path of varchar2 (5) of auth_d2 '. / author_data_02'
62, path of xmltype articles '. / Articles'
63                 ) y
64, xmltable ('/ Articles/article_item ')
from $ 65 y.articles
path id 66 number columns '. / article_id'
67, path of varchar2 (10) pub '. ' / publication.
68 road of varchar2 (10) dry '. / section'
69, path of varchar2 (10) of iss_dt '. / issue_date'
70 road of VARCHAR2 (3) pg '. "/ print this page"
71, path of varchar2 (20) of art_ttl '. / article_title'
72, path of varchar2 (5) of num_wrds '. / number_of_words'
73, path of varchar2 (5) of oprice '. / original_price'
74 road to VARCHAR2 (3) ocurr '. / original_price_currency'
75, path of varchar2 (5) price '. "/ price"
76, path of VARCHAR2 (3) curr '. / price_currency'
77*                ) z
SQL > /.

GEN_DATE GEN_BY YEAR MN AUTHOR AUTH_FN AUTH_LN AUT AUTH_EM AUTH_ AUTH_ ID PUB DRY ISS_DT PG ART_TTL NUM_W OPRIC HEARTS PRICE OCU
---------- --------------- ---- -- --------------- ---------- ---------- --- -------------------- ----- ----- ---------- ---------- ---------- ---------- --- -------------------- ----- ----- --- ----- ---
17/11/2015 Admin Admin 2015 01 user author user author [email protected] 123456 UAE Al Bayan Local 11/11/2015 2 is the title.   165 200 AED AED 250

Of course, you'll want to change the types of data, etc. as needed.

I assumed that the XML can contain several "" sections and that each section can contain several entries.

Thus the XMLTABLE aliasing as 'x' gives information of XML, and supplies the data associated with the XMLTABLE with alias 'y' which gets the multiple authors, which itself section of the XMLTABLE with alias 'z' for each of the article_item.

CDATA stuff are handled automatically by SQLX (XML functionality integrated into Oracle's SQL)

Tags: Database

Similar Questions

  • Select this OPTION to generate XML data from the table using XMLELEMENT, XMLAGG gives error ORA-19011 string buffer too small

    My select statement fails with the error:


    The ORA-19011 string buffer too small


    The select statement looks like:


    SELECT TO_CLOB)

    XMLELEMENT ("accounts",

    XMLELEMENT ("count",

    XMLATTRIBUTES)

    rownum AS "recordId."

    To_date('20130520','YYYYMMDD') AS "datestarted."

    123456 AS "previousBatchId."

    56789 AS 'previousRecordId '.

    ),

    ....

    .... .

    .....

    XMLFOREST)

    SIG_ROLE AS "SignatoryRole."

    To_char(TRANSFER_DATE,'YYYY-mm-DD') AS "TransferDate."

    NVL(Reason,0) AS 'reason '.

    ) AS the 'transfer '.

    )

    ()) AS CRDTRPT

    OF ANY_TABLE;

    • It looks like I can choose only 4000 characters using the SELECT statement (please, correct me if I'm wrong)

    I'd use the XMLGEN package. But the environment team says no mounted drives in the future with the arrival of the EXADATA.

    NO HARD DRIVE MOUNTED, NO ACCESS TO THE DATABASE DIRECTORIES

    No UTL_FILE

    I need to use the REEL spool the resulting XML data of the SELECT query.

    SQL is a standard in my org, but I can do with a PL/SQL solution also to load data into a table (cannot use a COIL with PL/SQL)

    What I do is:

    1. a column of type CLOB to a xml_report of the loading of the above SELECT query table
    2. Then using SELECT * FROM xml_report to SPOOL the data to a file report.xml

    No need of XMLTYPE data behind. Xml data stream is fine for me.

    In addition, I need to validate the XML file, also using XSD.

    Problem is that the resulting lines of the select query are supposed to be from 15000 to 20000 bytes long.

    Oracle database version: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    A Suggestion or a solution to this problem would be appreciated.

    (Sorry for the use of "BOLD", just to make it more readable and highlight the imp points)

    Bravo!

    Rahul

    It looks like I can choose only 4000 characters using the SELECT statement (please, correct me if I'm wrong)

    You use the right method.

    There is an implicit conversion from XMLType to the data type VARCHAR2 as expected by the function TO_CLOB, where the limitation, and the error.

    To serialize XMLType to CLOB, use the XMLSerialize function:

    SELECT XMLSerialize (DOCUMENT

    XMLELEMENT ("accounts",

    ...

    )

    )

    OF ANY_TABLE;

    For the rest of the requirement, I wish you good luck trying to spool the XML correctly.

    You may need to play around with the SET LONG and SET LONGCHUNKSIZE commands to operate.

  • Insert XML data from the Table-&gt; back to null

    Dear Experts,

    -I have table xml as below:

    Example of CREATE TABLE (XML_spec XMLTYPE);

    Insert in the example
    Select ' < name of Message = "dataStaticInvestor" type = "IncomingMessage" >
    < name of field = "batchReference" > OPENINGBATCH000000 < / field > < List name = "data" >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < / list >
    < / message > ' double.

    Select * example;

    create table hasil1 (c1 varchar2 (500), c2 varchar2 (500), c3 varchar2 (500));

    -This step I create the procedure to insert xml data into the table as the batch.

    DECLARE
    x XmlType;
    BEGIN
    Select XML_SPEC in x for example;

    insert into hasil1
    SELECT
    p.Extract('/Record/Field/@externalReference').getstringval (C1),
    p.Extract('/Record/Field/@participantID').getstringval (C2),
    p.Extract('/Record/Field/@participantName').getstringval () as c3
    TABLE (XMLSequence (Extract(x,'Message/List/Record'))) p;
    commit;
    END;
    /

    -when the result of select hasil1, the output is back 3 rows and 3 columns, but all data is a null *.

    Best regards
    Sigcle

    You don't explain what output you need, but I guess something like this:

    SQL> insert into hasil1 (c1, c2, c3)
      2  select x.c1, x.c2, x.c3
      3  from example t
      4     , xmltable(
      5         'Message/List/Record'
      6         passing t.xml_spec
      7         columns c1 varchar2(500) path 'Field[@name="externalReference"]'
      8               , c2 varchar2(500) path 'Field[@name="participantID"]'
      9               , c3 varchar2(500) path 'Field[@name="participantName"]'
     10       ) x
     11  ;
    
    3 rows inserted
    
    SQL> select * from hasil1;
    
    C1                     C2        C3
    ---------------------- --------- --------------------------------
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
     
    
  • Build the value of 100 mb of data in the table using the loop

    DB version: 11.2

    How can I create about 100 MB of test data in a table using minum number of records.
    If I use the below for loop. It takes 100,000 records to fill only 2 MB.
    SQL> create table a2 (mynum1 number, mynum2 number);
    
    Table created.
    
    begin
    for i in 1..100000 loop
        insert into a2 values(i,i*2);
    end loop;
    end;
    
    
    select segment_name, bytes/1024/1024 MB from dba_segments where segment_name = 'A2' AND owner='SCOTT'
    
    
    SEGMENT  BYTES/1024/1024
    -------- ---------------
    A2                     2

    Hello

    Is that what you are looking for?

    SQL> CREATE TABLE tbl1(c1 CHAR(1024));  -- ~1KB per row
    
    Table created.
    
    Elapsed: 00:00:00.00
    SQL> INSERT /*+ APPEND */ INTO tbl1 SELECT 'X' FROM dual CONNECT BY LEVEL < 100000; -- 100K rows * 1KB = 100MB + some additional overhead
    
    99999 rows created.
    
    Elapsed: 00:00:13.02
    SQL> SELECT bytes/1024/1024 MB FROM user_segments WHERE segment_name = 'TBL1';
    
            MB
    ----------
        113.75
    

    Lukasz

  • Load xml data into the table

    Hi all

    I have an XML (emp.xml) with data below:

    -< root >
    -< row >
    < name > steve < / lastname >
    < 30 > < / Age >
    < / row >
    -< row >
    < name > Paul < / lastname >
    <>26 < / Age >
    < / row >
    < / root >

    I would like to create a stored procedure to store the xml data into the EMP table.

    EMP
    LastName age
    Steve 30
    Paul 26

    I tried to watch all threads related to this forum, but cannot find the right wire. Any help is greatly appreciated. Thank you

    With

    SQL>  select * from xmltable('root/row' passing xmltype('
    
    steve
    30
    
    
    Paul
    26
    
    ') columns lastname path 'lastname',
                       Age path 'Age')
    /
    LASTNAME   AGE
    ---------- ----------
    steve      30
    Paul       26   
    

    You can now just make a

    Insert into emp as select...

  • How to add data to the table using Manager POST for restful Apex application

    Hi all

    I managed to create a service application web Manager restful using GET for the Restful service module. I am able to get the data in row on the presentation of a table row id in the application. But I can't find an appropriate example, how the new data in the table can be posted or deleted. I created a POST handler for a URI scheme and look forward on how to proceed. Any help would be really appreciated.

    Source for the POST Manager:

    Start

    insert into ALL_BOOKS values(:id,:book);

    end;

    Also created 2 parameters id and the book.

    Hi jerry2134,

    jerry2134 wrote:

    I managed to create a service application web Manager restful using GET for the Restful service module. I am able to get the data in row on the presentation of a table row id in the application. But I can't find an appropriate example, how the new data in the table can be posted or deleted. I created a POST handler for a URI scheme and look forward on how to proceed. Any help would be really appreciated.

    Source for the POST Manager:

    Start

    insert into ALL_BOOKS values(:id,:book);

    end;

    Also created 2 parameters id and the book.

    Check out the following tutorials OBE, that explains the creation of GET and POST RESTful Web Services and how to use them in the APEX.

    Also what yo mean "looking forward on how to proceed? Do you want to or created for use/consume in your Oracle APEX application hosted RESTful web services?

    If Yes, in your Application, you must create a RESTful Web Service reference -> shared components. Then, create a form/report based on Web Service reference.

    Kind regards

    Kiran

  • Error when inserting XML Date in the Table

    Hi all

    I am working on Oracle 11 g and trying to insert a date XML in the table but get error - below

    Query - insert into TableName (ID, CREATION, CREATEDBY) VALUES (50, *'2010 - 12-15 T 12: 57:19'*, 'Name')

    Error - java.sql.SQLDataException: ORA-01861: literal does not match the format string

    CREATED column datatype is Date

    When I try to use sysdate instead of hard-coding XML date of obtaining inserted successfully into the table. Please let me know how to pass this XML format date.

    Thanks in advance.

    Concerning
    Nikhil

    I don't see any XML in what you posted. In any case:

    "2010 12-15 T 12: 57:19'.

    is a string, not a date. Use:

    to_date('2010-12-15T12:57:19','YYYY-mm-dd"T"HH24:mi:SS')

    For example:

    SQL> create table tbl(created date);
    
    Table created.
    
    SQL> insert into tbl values('2010-12-15T12:57:19');
    insert into tbl values('2010-12-15T12:57:19')
                           *
    ERROR at line 1:
    ORA-01861: literal does not match format string
    
    SQL> insert into tbl values(to_date('2010-12-15T12:57:19','YYYY-MM-DD"T"HH24:MI:SS'))
      2  /
    
    1 row created.
    
    SQL> 
    

    SY.

  • Update of the data in the table using LAG/LEAD

    Hello!

    I have a table that looks like:

    CREATE TABLE CUSTOMER_INFO_TEST
    (
    ACCOUNT_NUM VARCHAR2 (40 BYTE),
    PHONE VARCHAR2 (100 BYTE),
    E-MAIL VARCHAR2 (300 BYTE),
    DATE OF START_DT,
    DATE OF CHANGE_DT,
    END_DT DATE
    );

    The example data:

    INSERT INTO CUSTOMER_INFO_TEST VALUES ('BOB', 555-1234', ", TO_DATE ('2011-01-01', 'YYYY-MM-DD'), TO_DATE ('2011-01-06', 'YYYY-MM-DD'), TO_DATE ('2011-01-10', 'YYYY-MM-DD'));
    INSERT INTO CUSTOMER_INFO_TEST VALUES ('BOB', 555-1234', ' BOB@GMAIL.) COM', TO_DATE ('2011-01-01', 'YYYY-MM-DD'), TO_DATE ('2011-01-11', 'YYYY-MM-DD'), NULL);
    INSERT INTO CUSTOMER_INFO_TEST VALUES ('BOB', 555-1234', ' BOB@GMAIL.) COM', TO_DATE ('2011-01-01', 'YYYY-MM-DD'), TO_DATE ('2011-01-15', 'YYYY-MM-DD'), NULL);
    INSERT INTO CUSTOMER_INFO_TEST VALUES ('JACK', 555-4321', ", TO_DATE ('01-03-2011', 'YYYY-MM-DD'), TO_DATE ('2011-03-06', 'DD-MM-YYYY'), NULL);
    INSERT INTO CUSTOMER_INFO_TEST VALUES ('JACK', 555-4321', ' JACK@GMAIL.) COM', TO_DATE ('01-03-2011', 'YYYY-MM-DD'), TO_DATE ('2011-03-11', 'YYYY-MM-DD'), NULL);

    My question:
    How can I configure end_dt (if null), to the next change_dt minus one

    It shows what I want to do:

    Select the rowid, account_num, phone, e-mail, start_dt, change_dt, end_dt, nvl (end_dt, lead (change_dt-1, 1) over (partition by account_num of start_dt order)) enddt CUSTOMER_INFO_TEST where end_dt is null;

    So, I want to update the table itself with the date in enddt. But how do I do this?

    This must be done in a single statement...

    Thanks in advance

    Richard

    Published by: user6702107 on 05-Jan-2011 09:11

    Edited by: Rydman on April 17, 2012 15:01

    Please post sample data!
    If your query returns the desired results, you can use the MERGE:

    SQL> select *
      2  from   customer_info_test;
    
    ACCOUNT_NU PHONE      EMAIL                     START_DT CHANGE_D END_DT
    ---------- ---------- ------------------------- -------- -------- --------
    BOB        555-1234                             01-01-11 06-01-11 10-01-11
    BOB        555-1234   [email protected]             01-01-11 11-01-11
    BOB        555-1234   [email protected]             01-01-11 15-01-11
    JACK       555-4321                             01-03-11 06-03-11
    JACK       555-4321   [email protected]            01-03-11 11-03-11
    
    5 rows selected.
    
    SQL> --
    SQL> merge into customer_info_test a
      2  using ( select rowid rid
      3          ,      nvl(end_dt, lead(change_dt-1, 1) over (partition by account_num order by start_dt)) new_end_dt
      4          from   customer_info_test
      5          where  end_dt is null
      6        ) b
      7  on (a.rowid = b.rid )
      8  when matched then update set a.end_dt = b.new_end_dt;
    
    4 rows merged.
    
    SQL> --
    SQL> select *
      2  from   customer_info_test;
    
    ACCOUNT_NU PHONE      EMAIL                     START_DT CHANGE_D END_DT
    ---------- ---------- ------------------------- -------- -------- --------
    BOB        555-1234                             01-01-11 06-01-11 10-01-11
    BOB        555-1234   [email protected]             01-01-11 11-01-11 14-01-11
    BOB        555-1234   [email protected]             01-01-11 15-01-11
    JACK       555-4321                             01-03-11 06-03-11 10-03-11
    JACK       555-4321   [email protected]            01-03-11 11-03-11
    
    5 rows selected.
    
  • Impossible to insert xml data into the table

    HII All,
    I'm unable to parse the following xml file and insert them into the table.


    Version of DB
    ======
    SQL> SELECT *
      2  FROM V$VERSION;
    
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    My DB Table
    Create table rgh_xml_storage
    (
    user_id       varchar2(4000),
    to_type          varchar2(4000),
    mail_id          varchar2(4000),
    subject         varchar2(4000),
    sentDateTime    varchar2(4000)
    )
    Published by: RUSSO April 7, 2011 04:19

    Hello

    Please provide all pertinent details!

    Please correct my insert if statement it must be.

    You have a few bad XPath.
    Here's a way to unnest correctly repeated elements:

    SQL> select x1.user_id,
      2         x1.subject,
      3         x1.sentDateTime,
      4         x2.to_type,
      5         x2.mail_id
      6         --x1.messageBody
      7  from xmltable(
      8    '/emailMessage'
      9    passing xmltype(bfilename('TEST_DIR','email.xml'), nls_charset_id('CHAR_CS'))
     10    columns user_id      varchar2(4000)  path 'headerInformation/sender/user/@userID',
     11            subject      varchar2(4000)  path 'headerInformation/subject',
     12            sentDateTime varchar2(4000)  path 'headerInformation/sentDateTime',
     13            messageBody  clob            path 'messageBody',
     14            my_xml       xmltype         path 'headerInformation/recipients'
     15   ) x1,
     16   xmltable(
     17    '/recipients/recipient'
     18    passing x1.my_xml
     19    columns to_type      varchar2(4000)  path '@type',
     20            mail_id      varchar2(4000)  path 'user/@emailAddress'
     21   ) x2
     22  ;
    
    USER_ID              SUBJECT                                          SENTDATETIME                   TO_TYPE   MAIL_ID
    -------------------- ------------------------------------------------ ------------------------------ --------- ------------------------------------------
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   to        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   cc        [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    RC58522              Re: CAA - Schlesinger ' Arnold   - LP01115771    Fri Oct 10 13:31:53 EDT 2010   bcc       [email protected]
    
    13 rows selected
     
    
  • Loading XML data in the tables

    Hi, I am currently working on a calendar of upcoming events. I have everything works fine, including the loading of an xml database based on the month and year in the temporary within the XML onLoad section tables, but my problem is obtaining data in a table that I can look in my DrawDays() function. Right now I'm pushing the content of the temporary table in loadXMLevent() in _root. Calendar.event_text_array and this table is filled up until I get into the DrawDays function. Any help would be greatly appreciated. I deleted the code associated with this email.

    Thank you!
    Chris

    You cannot call DrawDays() until loadEventArray() execution.

  • Update of the data in the Table using XMLTYPE DATA

    I did insertions using XMLTYPE data but have never done it and update. Can someone give me some advice?

    PROCEDURE ADD_LABORDER_CODES)

    IN_ORDERCODESXML IN CLOB DEFAULT NULL,

    Number of OUT OUT_AFFECTEDROWS

    )

    AS

    X SYS. XMLTYPE;

    BEGIN

    X: = SYS. XMLTYPE. CREATEXML (IN_ORDERCODESXML);

    INSERT INTO MAINT_LABORD_CODES)

    INSERT INTO MAINT_LABORD_CODES)

    LABORD_CODE_ID,

    COMPENDIUM_ID,

    ORDER_CODE,

    ORDER_DESC,

    ACTIVE,

    TIMESTAMP,

    MODIFIED_BY)

    SELECT MLOCDS_SEQ. NEXTVAL,

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/COMPENDIUM_ID') AS COMPENDIUM_ID,

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/ORDER_CODE') AS ORDER_CODE,

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/ORDER_DESC') AS ORDER_DESC,.

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/LOINC_CODE') AS LOINC_CODE,

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/ACTIVE') AS ACTIVE.

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/TIMESTAMP') AS TIMESTAMP.

    EXTRACTVALUE (VALUE (MLOC), '/ ORDERCODE/MODIFIED_BY') AS MODIFIED_BY

    TABLE (XMLSEQUENCE (EXTRACT(X,'/ORDERCODES/ORDERCODE'))) NMCO;

    OUT_AFFECTEDROWS: = NUMBER OF ROWS SQL %;

    EXCEPTION

    WHILE OTHERS THEN

    dbms_output.put_line (SQLERRM);

    RAISE_APPLICATION_ERROR (-20001, SQLERRM);

    END;

    Example of use of the FUSION-

    If the line exists in the target table (based on the COMPENDIUM_ID and ORDER_CODE values), the UPDATE is, if not to INSERT:

    declare
    
      in_ordercodesxml  clob :=
      '
      
        500
        696231
        ABO Group & Rh Type
        NULL
        12345
        Y
        2014-08-13
        1
      
    ';
    
    begin
    
      merge into maint_labord_codes t
      using (
        select compendium_id
             , order_code
             , order_desc
             , loinc_code
             , active
             , timestamp
             , modified_by
        from xmltable('/ORDERCODES/ORDERCODE'
               passing xmltype(in_ordercodesxml)
               columns COMPENDIUM_ID    number(10)    path 'COMPENDIUM_ID'
                     , ORDER_CODE       varchar2(50)  path 'ORDER_CODE'
                     , ORDER_DESC       varchar2(250) path 'ORDER_DESC'
                     , LOINC_CODE       varchar2(10)  path 'LOINC_CODE'
                     , ACTIVE           varchar2(1)   path 'ACTIVE'
                     , TIMESTAMP        date          path 'TIMESTAMP'
                     , MODIFIED_BY      number(10)    path 'MODIFIED_BY'
             )
      ) x
      on (     t.compendium_id = x.compendium_id
           and t.order_code = x.order_code )
      when matched then update
        set t.order_desc = x.order_desc
          , t.loinc_code = x.loinc_code
          , t.active     = x.active
          , t.timestamp  = x.timestamp
          , t.modified_by = x.modified_by
      when not matched then insert
      (
        labord_code_id
      , compendium_id
      , order_code
      , order_desc
      , loinc_code
      , active
      , timestamp
      , modified_by
      )
      values (
        mlocds_seq.nextval
      , x.compendium_id
      , x.order_code
      , x.order_desc
      , x.loinc_code
      , x.active
      , x.timestamp
      , x.modified_by
      );
    
    end;
    /
    

    Also note that I used XMLTABLE instead of TABLE/XMLSEQUENCE, which is much easier to use (and not deprecated in the latest versions).

    You have not precisely the date format in the TIMESTAMP element so I assumed a conform to W3C.

    If you have a problem with this part, return to a projection of VARCHAR2 and use TO_DATE with actual size.

  • including return transport with the XML data in the table

    I am inserting data using XML in a table in a context of InDesign.
    As part of the text, I would put a few carriage returns, so that the text has a line break where I like it rather than that InDesign can do its best estimate as to how to split the lines.

    I tried to put & #8629; and < br / > in the text, but has not been what I hoped, he might.

    Any suggestions?

    Thank you!

    Hello Urban, try this:

    
    

    Roland

  • whites in the data in the table using the formula node

    I have 2 tables 1 d of data go into a loop. Inside the loop, there is a formula node that combines the 2 sets numbers and did a little math for them. If the result of the calculation is 0, it means that the value is not valid. Nothing other than 0 is good value. The result of the calculation comes out the knot of the formula and leaves the loop becomes a table 1 d. Then my table is saved in a spreadsheet. 0 really screw up my graphics, and I want them to just be white instead. I tried to use NaN instead of 0, but who also live up to my graphics. How can I place white on the output instead of 0 array?

    It seems that your real problem is to define what will make Excel leave gaps.  For LV NaNs graphics to do what you want.

    You can also consider getting the output array an array of strings. There may be string values (NO?) that cause Excel jump.

    Lynn

  • Button insert data to the table

    Hello

    I use APEX 4.2.3 with XE, I try to insert data into the table using code below but nothing happen when I press the button, create this button like 'create a button to point to page'-> 'dynamic action'-> 'run pl/sql '.

    begin
    insert into dummy values('xx');
    commit;
    end;
    
    

    So to clarify, you have

    (1) created a button that "action" is "defined by the dynamic action.

    (2) created a dynamic action that executes pl/sql at the click on the button and you are pl/sql?

  • How to write a simple select query to get the data of the table as an XML.

    How to write a simple select query to get the data of the table as an XML. In the query, I'm just adding items below which i need be there in the XML document
    select '<test_tag>'||EMP_NAME||'</test_tag>','<date>'||sysdate||'</date>' 
    from temp_table where id_num BETWEEN 1 AND 10;
    I have need to add the root tag as well in the beginning and the end of < root > < / root > this xml file. Please advice if this is possible with the select query
    without using XMLGEN, XMLQUERY or any other packages built and function?

    I need to URL escapes with the UTF-8 code points that we have already achieved using the utl_http package. Please help how to do that without using the utl_http package.

    What is wrong with him?

    At present, the only way I can think of to avoid a call to UTL_HTTP. SET_BODY_CHARSET is to write your own little wrapper.
    In this way, you can specify the Boolean parameter or omit it if you choose to use named parameters:

    SQL> create or replace function my_url_escape (url in varchar2)
      2  return varchar2
      3  deterministic
      4  is
      5  begin
      6   return utl_url.escape(url, false, 'AL32UTF8');
      7  end;
      8  /
    
    Function created
    
    SQL> select my_url_escape('http://some.uri.com/param?lang=fr&text=contrôle') from dual;
    
    MY_URL_ESCAPE('HTTP://SOME.URI
    --------------------------------------------------------------------------------
    http://some.uri.com/param?lang=fr&text=contr%C3%B4le
     
    

Maybe you are looking for