How to insert document into xmltype column through an http post request with perl

Oracle 11.2.0.3
Windows server 2008r2
Apache tomcat 7.0
Oracle APEX 4.2.1
Oracle APEX Listener 2.0
I would like to insert a XML document into the database through an APEX restful web service. The POST into the web service in done with PERL. The following code will insert an empty record in a table with column of XMLType type.
Perl Code
use strict;
use warnings;
use LWP::UserAgent;
use HTTP:Headers;
my $headers = HTTP::Headers->new();
my $url = "http://host:port:apex/<application_workspace>/<restfull service module>/<uri template>/
my $sendthis = ('<?xml version="1.0" enconding="utf-8"?>
<students>
<row>
       <name>Mark</name>
      <age>30</age>
</row>
<./students>';)
$headers -> header('Content-Type' => 'text/xml; charset=utf-8');
my $request = HTTP:Request->new('POST', $url, $headers, $sendthis);
$request-> protocol('HTTP/1.1');
my $browser = LWP::UserAgent->new();
my $response = $browser->request($request);
my $gotthis= $response->content();
my $the_file_data = $response->content();
APEX restful service
Method: POST
Source type: PL/SQL
MIME Types allowed: blank
require secure access: none
source:
{declare
doc varchar2(32000);
begin
insert into table <column name>
values(doc);
commit;
end;
Table code
{ create table <tablename>
(column name XMLType>);
The above code will insert an empty column into the table.
Any ideas why?

It's a really bad idea to assemble XML using strings and string concatenation in SQL or PL/SQL. First there is a 4K limit in SQL, and 32K limit in PL/SQL, which means you end up constructing the XML in chunks, adding uneccessary complications. 2nd you cannot confirm the XML is valid or well formed using external tools.
IMHO it makes much more sense to keep the XML content seperated from the SQL / PL/SQL code
When the XML can be stored a File System accessable from the database, The files can be loaded into the database using mechansims like BFILE.
In cases where the XML must be staged on a remote file system, the files can be loaded into the database using FTP or HTTP and in cases where this is not an option, SQLLDR.
-Mark

Similar Messages

  • How to insert  data into BLOB column  using sql

    Hi all,
    How to insert data into BLOB column directly using sql .
    create  table temp
      a blob,
      b clob);
    SQL> /
    Insert into temp  values ('32aasdasdsdasdasd4e32','adsfbsdkjf') ;
    ERROR at line 1:
    ORA-01465: invalid hex number
    Please help in this.Thanks,
    P Prakash

    see this
    How to store PDF file in BLOB column without using indirect datastore

  • How to insert signals into multiple columns in db, dbtoolset

    I have  a labVIEW program that is currenly simulating voltage and a current signal using the DAQ Assistant. I'm using the database connectivity toolset. I am currently able to insert one signal into the database converted to a float(I can insert both into the same column as bianary but it needs to be stored as a usable format and in seperate columns.)
    The problem I am having is at the DB Tools Insert Data block. I have the connection, dbTable, error code, and create table boolean being passed into it. Where I am a little lost is how to set the columns I want to store the multiple signals into.
    If someone could break that part down for me that would be great. In short, I want to store voltage(channel0) and current(channel1) from the DAQ Assistant into their own respective columns in the db.

    As I have often pointed out, the easiest solution to this situation is to dump the Database Connectivity Toolkit. Check out this thread and follow the references in it. If the DCT weren't in the way what you are wanting to do would be very easy.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How To Insert Cells Into One Column Only

    Can anyone advise me, how to insert a cell (or multiple cells) into +just one column+ whilst leaving everything else on the sheet exactly as it is?
    I'm migrating from Excel and can't find this functionality in Numbers
    Thanks in advance for any help

    Thank you for taking the time to reply, thereby removing the misery of me continuing to search for this absent function!
    I really wanted to like the iWork apps! I recently rebuilt one of my rigs and had the intention of making it a Microsoft-free computer - hence the purchase of iWork.
    However, the last few days of 'learning curve' I have stumbled upon an increasing number of incompatibilities and limitations when compared to Excel, and the lack of the function to insert a single cell into a sheet is the final deal-breaker for me, sadly.
    So, reluctantly, I am going to install my Microsoft Office 2008 suite and get back to where I was before. I will continue to look at the iWork apps but I suspect they'll fall to the wayside.
    Once again, many thanks for confirming what I was reluctantly concluding.

  • How to insert fragment into xml column generated from query

    I'm trying to generate xml from some relational data and then insert a sub node into an xml column. Here's some sample code that obviously doesn't work.  I'm trying to figure out the syntax where the ???? exist.
    /* create test tables*/
    DECLARE @person TABLE
    id int NOT NULL PRIMARY KEY CLUSTERED,
    info xml NULL
    DECLARE @roles TABLE
    id int NOT NULL,
    role_name varchar(20) NOT NULL,
    PRIMARY KEY
    id,
    role_name
    /* insert test values */
    INSERT INTO @person (id, info)
    VALUES (1, '<person><name><first_name>Joe</first_name><last_name>Smith</last_name></name></person>'),
    (2, '<person><name><first_name>Tim</first_name><last_name>Jones</last_name></name></person>');
    INSERT INTO @roles (id, role_name)
    VALUES
    (1,'Admin'),
    (1,'User'),
    (2,'Editor'),
    (2,'User');
    /* make sure that xml comes back correctly*/
    SELECT
    role_name AS name
    FROM @roles AS role
    WHERE id = 1 -- works for each id
    FOR XML AUTO, ROOT ('roles');
    UPDATE p
    SET info.modify('insert ???? as last into (/person)[1]')
    FROM @person p
    INNER JOIN @roles r
    ON p.id = r.id
    /* desired output in the info column for id = 1*/
    <person>
    <name>
    <first_name>Joe</first_name>
    <last_name>Smith</last_name>
    </name>
    <roles>
    <role name="Admin" />
    <role name="User" />
    </roles>
    </person>
    Any ideas?

    this?
    DECLARE @person TABLE
    id int NOT NULL PRIMARY KEY CLUSTERED,
    info xml NULL
    DECLARE @roles TABLE
    id int NOT NULL,
    role_name varchar(20) NOT NULL,
    PRIMARY KEY
    id,
    role_name
    /* insert test values */
    INSERT INTO @person (id, info)
    VALUES (1, '<person><name><first_name>Joe</first_name><last_name>Smith</last_name></name></person>'),
    (2, '<person><name><first_name>Tim</first_name><last_name>Jones</last_name></name></person>');
    INSERT INTO @roles (id, role_name)
    VALUES
    (1,'Admin'),
    (1,'User'),
    (2,'Editor'),
    (2,'User');
    /* make sure that xml comes back correctly*/
    SELECT
    role_name AS name
    FROM @roles AS role
    WHERE id = 1 -- works for each id
    FOR XML AUTO, ROOT ('roles');
    UPDATE p
    SET info.modify('insert sql:column("x") as last into (/person)[1]')
    FROM @person p
    CROSS APPLY(SELECT role_name FROM @roles WHERE id = p.id FOR XML PATH(''),ROOT('roles'),TYPE)r(x)
    select * from @person
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How do I turn selected text in a Pages document into two columns without turning the whole document into two columns?

    How do I turn selected text in a Pages document into two columns without turning the whole document into two columns?

    Menu > Insert > Layout Break (before and after text) > click in text > Inspector > Layout > Layout > columns: 2
    Peter

  • Insert a XSL document into XMLType

    Hi dear reader
    I want to insert a XSL document into XMLType field , but the length of the XSL is 5900 character and I have problem with loading and executing the INSERT statement in database.
    for solving the load problem , I use binding variable and try to execute it with EXECUTE IMMEDIATE str.
    and get the following error :
    ORA-01704: string literal too long
    please advice;
    thanks

    create directory object DIR_TEMP on the database pointing to the physical path where your xml files are available.
    Note the path should be on the database server and not on the client and also your files should be present on the database server and not client for this to work.
    create table xml_table (id number, xml_data xmltype)
    CREATE OR REPLACE FUNCTION getClobDocument
    ( filename  in varchar2,
      charset   in varchar2 default NULL,
      dir       IN VARCHAR2 default 'DIR_TEMP',
    ) RETURN CLOB deterministic is
      file          bfile := bfilename(dir,filename);
      charContent   CLOB := ' ';
      targetFile    bfile;
      lang_ctx      number := DBMS_LOB.default_lang_ctx;
      charset_id    number := 0;
      src_offset    number := 1 ;
      dst_offset    number := 1 ;
      warning       number;
    BEGIN
      IF charset is not null then
          charset_id := NLS_CHARSET_ID(charset);
      end if;
      targetFile := file;
      DBMS_LOB.fileopen(targetFile, DBMS_LOB.file_readonly);
      DBMS_LOB.LOADCLOBFROMFILE(charContent, targetFile,
      DBMS_LOB.getLength(targetFile), src_offset, dst_offset,
      charset_id, lang_ctx,warning);
      DBMS_LOB.fileclose(targetFile);
      return charContent;
    end;
    insert into xml_table values(1, XMLTYPE(GetClobDocument('purchaseorder.xml')))
    /The function GetClobDocument returns the content of the xml file in CLOB format.
    Before insert this is converted into XMLTYPE.

  • How to Insert Hastables Into Database Through JDBC

    hi all,
    I have place the Data from the Hashtables Into the Database.I can place it by Iterating through the Hastables.I would Like to Place the Entire Hashtable Itself Into the Database.
    Can Any one tell me how?
    bye.

    Hi,
    Can anyone help me out how to insert image into
    database using struts...with dao n dto classes?If it matters whether or not you are using struts then you might have something wrong.
    Make sure you separate the database logic out.
    I know these types of questions are asked frequently, you might want to search the forum for additional examples.
    Here is a good one:
    http://forum.java.sun.com/thread.jspa?threadID=620455&messageID=3495899

  • How to insert data into newly added column

    Hi all,
    i am having a doubt how to insert entries into newly added column..
    i created a table with two columns and inserted the data into them then i altered the table by adding additional column.now i want to insert data into that..plz tell me how to do that..??
    thanks in advance..help me

    Small example:
    [email protected]> create table t(id int, id2 int);
    Table created.
    [email protected]> insert into t values (1,2);
    1 row created.
    [email protected]> insert into t values (2,2);
    1 row created.
    [email protected]> alter table t add id3 int;
    Table altered.
    [email protected]> select * from t;
    ID ID2 ID3
    1 2
    2 2
    [email protected]> update t
    2 set id3 = 10
    3 where id = 1;
    1 row updated.
    [email protected]> select * from t;
    ID ID2 ID3
    1 2 10
    2 2
    Best Regards
    Krystian Zieja / mob

  • How to insert data into table control

    hi experts,,
           i have inserted data into data base table through table control .
    now i want to insert data into table control through database table.
      how to delete data from table control for selected row

    Hi
    go through this link.
    http://www.****************/Tutorials/ABAP/TableControl/Demo.htm

  • Can any one tell me how to break this into separate columns 05/13/2014,"46","48","37","70","74","1","2","121000000.0000"

    Can any one tell me how to break this into separate columns 05/13/2014,"46","48","37","70","74","1","2","121000000.0000"

    Paste your content into TextEdit. Format > Make Plain Text.
    Comand-S to save.
    Command-Click the filename at the top of the TextEdit window. Click on the second line, the name of the folder where you saved the document.
    Select the extension of the document Name in the finder window that is being displayed and replace TXT with CSV.
    Right-Click the csv file and choose Open With > Numbers.
    Numbers will open with a column for each field in your data.
    Jerry

  • CS 5.5 How to insert header into pre-fab design --- from a sophomoric neophyte

    CS 5.5 How to insert header into pre-fab design --- from a sophomoric neophyte
    Essentially, I have one basic HTML class from several years ago, and a beginning DW class in 2008.
    i am trying to figure out if I can insert a header or otherwise edit the top of this pre-fab DW site.
    http://www.doyle.thibert.com/neos/index.html
    Thanks in advance for your sage advice.
    Doyle

    Learn all you can about HTML and CSS first.  DW expects you to know coding fundamentals. 
    HTML, CSS & Web Design Theory Tutorials -
    http://w3schools.com/
    http://www.csstutorial.net/
    http://phrogz.net/css/HowToDevelopWithCSS.html
    http://webdesign.tutsplus.com/sessions/web-design-theory/
    Then work through David Powers' 5-part tutorial
    Creating  your first web site in DW -
    http://www.adobe.com/devnet/dreamweaver/articles/first_website_pt1.html
    Good luck!
    ❄  ☃  ❄Nancy O.

  • How to insert data in BLOB column??

    How to insert data in BLOB column.
    Create table BLOBTest (message BLOB)
    insert into blobtest
    (message)
    values
    ('I am loving it');
    gives error ORA-01465: invalid hex number.

    ('I am loving it');This is not considered Binary (BLOB) data. Are you sure you don't want a Character (CLOB) column?

  • How to insert data into two tables linke with foreign key..

    I have two tables
    1)EMP(emp_ID,username,emp_type_code)
    emp_ID is primary key, emp_type_code is a foreign key references emptype table.
    2)emptype(emp_type_code,emp_type_descripton)
    emp_type_code is primary key
    Could anyone help me ..how to insert data into EMP table. How to insert data into two tables linke with foreign key..

    CREATE TABLE "CATDB"."DWDIMUSER"
    "USER_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SPECIALTY_ID" NUMBER(10,0),
    "FULLNAME" VARCHAR2(20 BYTE),
    "FNAME" VARCHAR2(20 BYTE),
    "LNAME" VARCHAR2(20 BYTE),
    "USER_SUBTYPE" VARCHAR2(20 BYTE),
    CONSTRAINT "DIMUSER_PK" PRIMARY KEY ("USER_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE,
    CONSTRAINT "DIMUSER_DIMSPECIALTY_FK" FOREIGN KEY ("SPECIALTY_ID") REFERENCES "CATDB"."DWDIMSPECIALTY" ("SPECIALTY_ID") DISABLE
    CREATE TABLE "CATDB"."DIMSPECIALTY"
    "SPECIALTY_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SPECIALTY_NAME" VARCHAR2(100 BYTE),
    CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("SPECIALTY_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
    INSERT INTO DIMUSER (FullName, FNAME, LNAME, USER_TYPE, USER_SUBTYPE)
    SELECT DISTINCT
    Engineer AS FullName,
    regexp_substr(Engineer , '[^,| ]+', 1, 1) as FName,
    regexp_substr(Engineer , '[^,| ]+', 1, 2) as LName ,
    'Engineer'
    FROM EMPLOYEELOOKUP;
    INSERT INTO DIMSPECIALTY (SPECIALTY_NAME)
    SELECT DISTINCT SPECIALITY
    FROM EMPLOYEELOOKUP;
    COMMIT;
    CREATE TABLE employeelookup ...IS A TABLE THAT HAS ALL THE DATA NEDED TO BE FILLED IN BOTHE TABLES...
    CREATE TABLE "CATDB"."EMPLOYEELOOKUP"
    "EMPLOYEELOOKUP_ID" NUMBER(10,0) NOT NULL ENABLE,
    "ENGINEER" VARCHAR2(25 BYTE),
    "SPECIALTY" VARCHAR2(20 BYTE),
    CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("EMPLOYEELOOKUP_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
    DATA IN EMPLOYEELOOKUP
    Engineer, Specialty,
    John, Dow, Electronis,
    Dow, Jons, Technician
    Stan Smithers Sales
    Mark, Richards Marketing
    Jenny, Lane Marketing
    John, Lee Sales
    I NEED TO LOAD THE FOREIGN KEY IN DIMUSER FROM THE DIMSPECIALTY TABLE?
    BY USING THE LOOKUP TABLE TO MARCH THE NAMES UNDER THE Engineer COLUMN, SPECIALTY COLUMNE DISTICTIVLY BY JOINING THE DIMSPECILTY TO RISTIVE THE PRIMARY KEY AND FILL IT IN THE DIMUSER TABLE AS A FOREIGNE KEY.

  • Please could someone tell me how to insert colour into my calendar text, especially coloured Highlights. Thanks.

    please could someone tell me how to insert colour into my calendar text, especially coloured Highlights. Thanks.

    Another netbook is not a desktop computer.
    Have you transferred your iTunes library from the backup for the laptop that died along with all other important data to the new computer such as documents, photos, etc.?
    If not, all iTunes content on your iPhone will be erased as the first step when syncing the iPhone with iTunes on a new or different computer.
    Have you launched iTunes on the new computer?
    Is you iPhone avaialble under Devices in the iTunes source list on the new computer?

Maybe you are looking for