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
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 Prakashsee this
How to store PDF file in BLOB column without using indirect datastore -
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.
DoyleLearn 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 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 -
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 helpThank 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 data into custom database table from an hcsf
i want to insert data into database table that i have created from an hcsf.
example :
say i have created a table in oracle database and i hav created a hcsf file.now i want that when somebody fills in that hcsf and click submit ,i want that entries should be updated in my database table.
plzzz reply ASAP(it's urgent)you'll need a bit of Java code... extract the data during a check-in filter, and insert it into the database.
check out the "DataAccess" component in the HowToComponents for query-running examples, and the "DynamicPrefix" component for a check-in filter example.
I have older copies here:
http://bezzotech.com/library -
How To Insert Data into a Access Database from a PDF File
Hi All,
Could anyone help me to insert PDF form data to an MS Access database.I am new to this and I would appreciate if anyone can help me at the earliest.
Thanks,
DeeptiYou can submit your PDF to a server-side script (ASP/PHP), and store the new record in a MS Access database.
For more information on how to store your PDF submission in a database, please visit:
http://www.fdftoolkit.net -
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 meSmall 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 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. -
How to insert data into the mysql table by giving as a text file
Hi,
Any one know's how to insert data into the mysql table by giving as a text file as the input in JSP.Please respond ASAP.
Thanks:)At least you can try StringTokenizer to parse your text files. Or download a text JDBC driver to parse your files, for instance, HXTT Text(www.hxtt.net) or StelsCSV(www.csv-jdbc.com).
-
Its very urgent:how to insert data into database tables
Hi All,
I am very new to oaf.
I have one requirement data insert into database tables.
here createPG having data that data insert into one custom table.
but i dont know how to insert data into database tables.
i wrote the code in am,co as follows.
in am i wrote the code:
public void NewoperationManagerLogic()
ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();
OADBTransaction oadbt=getOADBTransaction();
if(!vo1.isPreparedForExecution())
vo1.executeQuery();
Row row=vo1.createRow();
vo1.insertRow(row);
in createPG processrequest co:
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.NewoperationManagerLogic();
process form request:
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
if(pageContext.getParameter("Submit")!=null)
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.getOADBTransaction().commit();
please help with an example(sample code).
its very urgent.
thanks in advance
Seshu
Edited by: its urgent on Dec 25, 2011 9:31 PMHi ,
1.)You must have to create a EO based on custom table and then VO based on this EO eventually to save the values in DB
2.) the row.setNewRowState(Row.STATUS_INITIALIZED); is used to set the the status of row as inialized ,this is must required.
3.) When u will create the VO based on EO the viewattributes will be created in VO which will be assigned to the fields to take care the db handling .
You must go thtough the lab excercise shipped with you Jdeveloper ,there is a example of Create Employee page ,that will solve your number of doubts.
Thanks
Pratap -
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 -
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
Maybe you are looking for
-
Hi, I'm in the process of trying to automate some pdf tasks. We currently scan in records, make them searchable via OCR, and combine them in groups into a portfolio. The portfolio part requires a lot of manual processing. In the batch processor I'
-
ICloud Log in not working for iOS8
I have just updated my software on an iphone 5 to iOS8. However, I have had to reset my iCloud password and now I am not able to log into iCloud. When trying to log in the validation keeps telling me that my apple id password is incorrect.
-
hi , i want to give HOT KEYS as the access key attribute for my adf faces core components. for example, i have a af:input text field,. i want to keep access key for it as HOT KEY(F1 or any hot key upto F12).. is it possible to keep hot keys as access
-
In alv list display of the NR19 transaction, how to trigger new page automatically depending of the order type. By example: a new page every time that change the attending physician.
-
Can I upgrade to Elements 11?
Is it possible to upgrade Elements 10 to Elements 11, w/o going to 12?