SQL Functions to Update XML Data
Hi,
Can anybody please tell me whether SQL Functions to Update XML Data (such as updateXML, insertChildXML, insertXMLbefore etc) are available with oracle 9i or not?
Please tell me.
You can also do a describe on SYS.XMLTYPE to see what methods are supported in your release. How would you find e.g. insertChildXML in DESC sys.xmltype? I suppose it is not a Method of the Type: Summary of XMLType Subprograms.
Similar Messages
-
Update XML data stored in CLOB Column
Hi All,
i am new to Oracle and new to SQL
i am trying to update XML data stored in CLOB cloumn,data is stored with the follwoing format
<attrs><attr name="name"><string>Schade</string></attr></attrs>
i am using the following query for updating the value
UPDATE PRODUCT p SET ATTRIBUTES_nl_nl=UPDATEXML(XMLTYPE.createXML(ATTRIBUTES_nl_nl),'/attrs/attr[@name="name"]/string/text()','Schade').getClobVal() WHERE p.sku='000000000000040576_200911-5010057'
this query is working fine but it changing the data to the following format
<attrs><attr name="name">Schade</attr></attrs>
some how it is ommiting the <string> tag from it, i am unable to figure it out whats the reason.
any help in this regard will b e much appriciated
Thanks in Advance
-UmeshHi,
You should have created your own thread for this, and included database version.
This works for me on 11.2.0.2 and 10.2.0.5 :
SQL> create table t_org ( xml_clob clob );
Table created
SQL>
SQL> insert into t_org
2 values(
3 '<Message>
4 <Entity>
5 <ASSIGNMENT>
6 <OAVendorLocation> </OAVendorLocation>
7 <Vendorid>1</Vendorid>
8 </ASSIGNMENT>
9 </Entity>
10 </Message>'
11 );
1 row inserted
SQL> commit;
Commit complete
SQL> select '*' ||
2 extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
3 || '*' as result
4 from t_org;
RESULT
SQL> update t_org set xml_clob =
2 updatexml(xmltype(xml_clob),
3 '/Message/Entity/ASSIGNMENT/OAVendorLocation/text()','LONDON').getClobVal()
4 ;
1 row updated
SQL> select '*' ||
2 extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
3 || '*' as result
4 from t_org;
RESULT
*LONDON*
Does the OAVendorLocation really have a whitespace value?
If not then it's expected behaviour, you're trying to update a text() node that doesn't exist. In this case, the solution is to use appendChildXML to create the text() node, or update the whole element.
Is it your real document? Do you actually have some namespaces? -
SQL Loader fails loading XML data enclosed by tag not found
The problem I'm having is my XML tree doesn't contain all possible elements. In this example the second entry doesn't contain <age> - only the first entry will be added to the database
Any idea of how I could solve this?
The fields are saved as varchar2
XML:
<rowset>
<row>
<name>Name</name>
<age>Age</age>
<city>City</city>
</row>
<row>
<name>Name2</name>
<city>City2</city>
</row>
</rowset>
LOAD DATA
INFILE 'data.xml' "str '</row>'"
APPEND
INTO TABLE test
TRAILING NULLCOLS
dummy FILLER terminated BY "<row>",
name ENCLOSED BY "<name>" AND "</name>",
age ENCLOSED BY "<age>" AND "</age>",
city ENCLOSED BY "<city>" AND "</city>"
)I noticed that failure occurs when using 11g version SQL Loader. It doesn't fail when using 10g version SQL Loader.
Delimited source data comes from:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - ProductionAnd will be loaded into
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - ProductionMy previously used SQL Loader was from:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - ProductionIt seems that I have found the real culprit. Should I know something more? -
PL/SQL Function: Adding Days to Date
I have a function that adds a given number of days to a date, and excludes Saturday, Sunday, or Monday if needed with parameters. The problem is when the given date is a Friday, you need to add one day, and you exclude Saturday and Sunday i.e. DAYSBETWEEN('30-SEP-11',1,1,1,0) or DAYSBETWEEN('30-SEP-11',1,1,1,1).
Where am I going wrong here and what needs to be fixed?
create or replace
FUNCTION daysbetween(
DAYIN IN DATE ,
ADDNUM IN NUMBER ,
EXSAT IN NUMBER ,
EXSUN IN NUMBER ,
EXMON IN NUMBER )
RETURN DATE
IS
dtestart DATE;
dteend Date;
intcount NUMBER;
BEGIN
WITH all_dates AS
(SELECT LEVEL AS days_to_add ,
dayin ,
dayin + LEVEL AS new_dt ,
addnum ,
exsat ,
exsun ,
exmon
FROM dual
CONNECT BY LEVEL <= addnum * 2
exclusions AS
(SELECT ROW_NUMBER() OVER ( ORDER BY new_dt) ordering ,
addnum ,
new_dt ,
TO_CHAR ( new_dt, 'DY' )
FROM all_dates
WHERE 1 =1
AND TO_CHAR ( new_dt, 'DY' ) != DECODE ( exsat, 1, 'SAT', 'XXX')
AND TO_CHAR ( new_dt, 'DY' ) != DECODE ( exsun, 1, 'SUN', 'XXX')
AND TO_CHAR ( new_dt, 'DY' ) != DECODE ( exmon, 1, 'MON', 'XXX')
SELECT MAX( new_dt ) INTO dteend FROM exclusions WHERE ordering <= addnum;
RETURN dteend;
END daysbetween;You could do something in SQL like this perhaps...
SQL> ed
Wrote file afiedt.buf
1 with x as (select rownum as days_to_add from dual connect by rownum <= 31)
2 ,y as (select sysdate as dt from dual)
3 --
4 -- end of test data
5 --
6 select dt, days_to_add
7 ,case when to_char(new_dt,'fmDAY') IN ('SATURDAY','SUNDAY') then new_dt + 2
8 else new_dt
9 end as new_dt
10 from (
11 select dt
12 ,days_to_add
13 ,dt
14 +floor(days_to_add/5)*7
15 +mod(days_to_add,5) as new_dt
16 from x,y
17* )
SQL> /
DT DAYS_TO_ADD NEW_DT
05-OCT-2011 16:33:27 1 06-OCT-2011 16:33:27
05-OCT-2011 16:33:27 2 07-OCT-2011 16:33:27
05-OCT-2011 16:33:27 3 10-OCT-2011 16:33:27
05-OCT-2011 16:33:27 4 11-OCT-2011 16:33:27
05-OCT-2011 16:33:27 5 12-OCT-2011 16:33:27
05-OCT-2011 16:33:27 6 13-OCT-2011 16:33:27
05-OCT-2011 16:33:27 7 14-OCT-2011 16:33:27
05-OCT-2011 16:33:27 8 17-OCT-2011 16:33:27
05-OCT-2011 16:33:27 9 18-OCT-2011 16:33:27
05-OCT-2011 16:33:27 10 19-OCT-2011 16:33:27
05-OCT-2011 16:33:27 11 20-OCT-2011 16:33:27
05-OCT-2011 16:33:27 12 21-OCT-2011 16:33:27
05-OCT-2011 16:33:27 13 24-OCT-2011 16:33:27
05-OCT-2011 16:33:27 14 25-OCT-2011 16:33:27
05-OCT-2011 16:33:27 15 26-OCT-2011 16:33:27
05-OCT-2011 16:33:27 16 27-OCT-2011 16:33:27
05-OCT-2011 16:33:27 17 28-OCT-2011 16:33:27
05-OCT-2011 16:33:27 18 31-OCT-2011 16:33:27
05-OCT-2011 16:33:27 19 01-NOV-2011 16:33:27
05-OCT-2011 16:33:27 20 02-NOV-2011 16:33:27
05-OCT-2011 16:33:27 21 03-NOV-2011 16:33:27
05-OCT-2011 16:33:27 22 04-NOV-2011 16:33:27
05-OCT-2011 16:33:27 23 07-NOV-2011 16:33:27
05-OCT-2011 16:33:27 24 08-NOV-2011 16:33:27
05-OCT-2011 16:33:27 25 09-NOV-2011 16:33:27
05-OCT-2011 16:33:27 26 10-NOV-2011 16:33:27
05-OCT-2011 16:33:27 27 11-NOV-2011 16:33:27
05-OCT-2011 16:33:27 28 14-NOV-2011 16:33:27
05-OCT-2011 16:33:27 29 15-NOV-2011 16:33:27
05-OCT-2011 16:33:27 30 16-NOV-2011 16:33:27
05-OCT-2011 16:33:27 31 17-NOV-2011 16:33:27
31 rows selected. -
Function module updating the data base table
Hi,
This post is regarding the function module not updating the data base table.
I am calling the FM SD_SHIPMENT_HEADER_CHANGE inside the ZFM. It's returning success an changing the table c_xvttk_new with the new TDLNR value. But it's not updating the Shipment table VTTK-TDLBR or VT02N Forwarding agent.
When I directly updating Forwarding agent in VT02N it's updating fine.
Please let me know what the extra step need to be included to update or COMMIT the FM for updating
Forwarding Agent(VTTK-TDLNR).
Best Regards,
Maheshhi friend,
This link wont five u the complete help but if u ananyse it then it might provide u some idea......
BAPI change shipment doc
regards
kanishak -
Regarding sql function error for Hijri date to Gregorian date
Hi ,
I want to convert Hijri date format into Gregorian date format . i write the script with sql function like this
$Hijri_Date = '16/04/1428';
$Gregorian_Date = sql('DS_REPO','SELECT CONVERT(DATE,[$Hijri_Date],131)');
print($Gregorian_Date);
here $Hijri_Date data type is varchar and $Gregorian_Date data type is date.
but I am getting error like
7868 5812 DBS-070401 10/26/2010 10:37:18 PM |Session Job_Hijradata_Conversion
7868 5812 DBS-070401 10/26/2010 10:37:18 PM ODBC data source <UIPL-LAP-0013\SQLEXPRESS> error message for operation <SQLExecute>: <[Microsoft][SQL Server Native Client
7868 5812 DBS-070401 10/26/2010 10:37:18 PM 10.0][SQL Server]Explicit conversion from data type int to date is not allowed.>.
7868 5812 RUN-050304 10/26/2010 10:37:18 PM |Session Job_Hijradata_Conversion
7868 5812 RUN-050304 10/26/2010 10:37:18 PM Function call <sql ( DS_REPO, SELECT CONVERT(DATE,16/04/1428,131) ) > failed, due to error <70401>: <ODBC data source
7868 5812 RUN-050304 10/26/2010 10:37:18 PM <UIPL-LAP-0013\SQLEXPRESS> error message for operation <SQLExecute>: <[Microsoft][SQL Server Native Client 10.0][SQL
7868 5812 RUN-050304 10/26/2010 10:37:18 PM Server]Explicit conversion from data type int to date is not allowed.>.>.
7868 5812 RUN-053008 10/26/2010 10:37:18 PM |Session Job_Hijradata_Conversion
please help me out to solve this problem .
Please suggest any other solution to convert hijri date format to gregorian date format.
Thanks&Regards,
Ramana.Hi ,
In Data quality there is no inbuild function for converting hijri date to gregorian date . we have the function for converting julian date to gregorian date.
Thanks&Regards,
Ramana. -
Oracle sql function to find VARCHAR2 data is numeric
Hi Everyone,
Is there oracle sql function to find whether the VARCHAR2 data is numeric?
Thankshi,
see the below example .
with t as
(select '12' as col from dual union all
select '1 2' as col from dual union all
select '2 1 3' as col from dual union all
select 'abcde' as col from dual union all
select '12345' as col from dual union all
select '1a4A5' as col from dual union all
select '12a45' as col from dual union all
select '12aBC' as col from dual union all
select '12abc' as col from dual union all
select '12ab5' as col from dual union all
select '12aa5' as col from dual union all
select '12AB5' as col from dual union all
select 'ABCDE' as col from dual union all
select '123-5' as col from dual union all
select '12.45' as col from dual union all
select '1a4b5' as col from dual union all
select '1 3 5' as col from dual union all
select '1 45' as col from dual union all
select '1 5' as col from dual union all
select 'a b c d' as col from dual union all
select 'a b c d e' as col from dual union all
select 'a e' as col from dual union all
select 'Steven' as col from dual union all
select 'Stephen' as col from dual union all
select '111.222.3333' as col from dual union all
select '222.333.4444' as col from dual union all
select '333.444.5555' as col from dual union all
select 'abcdefabcdefabcxyz' as col from dual union all
select 'aaa' as col from dual union all
select 'ddd' as col from dual union all
select 'ccc' as col from dual union all
select 'aaaaa' as col from dual union all
select 'aaaaaaaa' as col from dual
select * from t where regexp_like(col,'[1-9]')
Result
COL
12
1 2
2 1 3
12345
1a4A5
12a45
12aBC
12abc
12ab5
12aa5
12AB5
123-5
12.45
1a4b5
1 3 5
1 45
1 5
111.222.3333
222.333.4444
333.444.5555Thanks,
P Prakash -
Sql query generator from xml data
Hi,
I am looking for an open source tool in java which would generate the sql query with an xml configuration file as input. The xml configuration file schema would be defined by the tool and and would provide placeholders for giving the various information required to build the sql query.
Are there any available?
Please let me know.
Anshukhi All,
I tried below . but still no luck .
CREATE OR REPLACE FUNCTION get_audit_trail_log(cikey IN INTEGER) RETURN blob IS
CURSOR c_log(l_cikey INTEGER) IS
SELECT *
FROM PROD_SOAINFRA.audit_details atr
WHERE cikey = l_cikey
ORDER BY count_id;
bl BLOB;
BEGIN
dbms_lob.createtemporary (bl, TRUE);
FOR r_log IN c_log(cikey)
LOOP
dbms_lob.append (bl,r_log.log);
END LOOP;
RETURN(bl);
END;
=======================================
SELECT UTL_RAW.CAST_TO_VARCHAR2(UTL_COMPRESS.LZ_UNCOMPRESS(get_audit_trail_log(ci.cikey)))
FROM PROD_SOAINFRA.audit_details ci
WHERE cikey = 848063749
=======================================
Error:
=====================
ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 20958, maximum: 2000)
22835. 00000 - "Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: %s, maximum: %s)"
*Cause: An attempt was made to convert CLOB to CHAR or BLOB to RAW, where
the LOB size was bigger than the buffer limit for CHAR and RAW
types.
Note that widths are reported in characters if character length
semantics are in effect for the column, otherwise widths are
reported in bytes.
*Action: Do one of the following
1. Make the LOB smaller before performing the conversion,
for example, by using SUBSTR on CLOB
2. Use DBMS_LOB.SUBSTR to convert CLOB to CHAR or BLOB to RAW. -
SQL function to extract XML namespace prefix
Hi,
I have the following document
<ns4:product xmlns:ns1="www.abc.com" xmlns:ns2="www.def.com" xmlns:ns3="www.ghi.com" xmlns:ns4="www.jkl.com">
<ns4:productline>Widget</ns4:productline>
</ns4:product>
I'm trying to find a SQL function which will enable me to extract the namespace prefix with the value "www.jkl.com". This is so that I can then use the prefix as part of the xpath expression to search for an element value in the document eg. extractvalue('/ns4:product/ns4:productline')
ThanksTry DBMS_XMLDOM.GetNameSpace
-
How to call a PL/SQL procedure from a xml Data Template
We have a requirement in which we need to call a pl/sql package.(dot)procedure from a Data Template of XML Publisher.
we have registered a Data Template & a RTF Template in the XML Publisher Responsibility in the Oracle 11.5.10 instance(Front End).
In the Data Query part of the Data Template , we have to get the data from a Custom View.
This view needs to be populated by a PL/SQL procedure.And this procedure needs to be called from this Data Template only.
Can anybody suggest the solution.
Thanks,
SachinCall the procecure in the After Parameter Form trigger, which can be scripted in the Data Template.
BTW, there is a specialized XML Publisher forum:
BI Publisher -
I have the following code in place to move a variable from my
Flash app to an XML file for storage . . .
//replace the GoodVN value in the XML file with the latest
valid voucher number
var VoucherNumbers:XML = new
XML("<VoucherNumbers><GoodVoucher>VoucherNo</GoodVoucher>
</VoucherNumbers>");
VoucherNumbers.contentType = "text/xml";
VoucherNumbers.send("VoucherNumbers.xml");
But this is not working. I cannot use LoadVars as it is meant
for use with a .txt file. I have tried other variations on this
code but with little success.
My XML file has the following layout . . .
<?xml version="1.0" encoding="UTF-8" ?>
- <VoucherNumbers>
<GoodVoucher>20060820151601</GoodVoucher>
- <CancelVoucher>
<CancelledVoucher>20060820091501</CancelledVoucher>
<CancelledVoucher>20060820102201</CancelledVoucher>
<CancelledVoucher>20060820105401</CancelledVoucher>
<CancelledVoucher>20060820114201</CancelledVoucher>
</CancelVoucher>
</VoucherNumbers>
So . . . how do I go about getting my VoucherNo variable from
Flash to replace the value in the GoodVoucher field in my XML file?Flash is read only. You need some sort of serverside script
to write data to
a file. php, cfm, asp, cgi or perl.
There is a sample here that uses php to update an xml file
that displays a
guestbook:
http://www.kirupa.com/web/xml_guestbook3.htm
Dan Mode
--> Adobe Community Expert
*Flash Helps*
http://www.smithmediafusion.com/blog/?cat=11
*THE online Radio*
http://www.tornadostream.com
*Must Read*
http://www.smithmediafusion.com/blog
"Goo101" <[email protected]> wrote in
message
news:ecega6$1nq$[email protected]..
> Why can't you use the .send method to load data into a
locally stored XML
> file?
> Can anyone out there please answer my question!? I find
it absurd that you
> can
> read data in from a locally stored XML object but not
update or write to
> it!
> -
Does any one know how or if you can update or insert new data
into an xml file from Flash AS3?
An example would be someone filling out and submitting a form
and then the information entered is sent to the xml file to create
or update nodes in the xml file.
Thanks in advance.You can't do that from the flash player directly.
You can do it via a server side script, e.g. using a php
script that processes the request from flash, but often data in
this type of scenario would be stored in a database instead of an
xml file (however using php for updating an xml file is entirely
possible too) -
How to automatically update xml data for xml connector
I suspect the answer to this is simple because I am a real novice when it comes to ActionScript.
I have a project with an XML Connector that goes out and gets data from an xml file and displays it in a label in my flash.
It does this when the swf file loads using ActionScript in frame 1.
The ActionScript is simply:
this.labels_xc.trigger();
This is great. It loads the data from the XML file no problem. But the data in the XML file changes every so often. How do I get the swf file to go out and get the new data on a regular interval (say every 2 minutes or so)? I've looked at scripts with timers and I can't figure it out.
Here is the url to the page I'm testing it on:
http://www.timescapemedia.com/uptake/text.htmlMy lack of experience here is showing.
I tried putting the following, but neither work.
this.labels_xc.trigger();
setInterval(f, 30000);
function f() {
this.labels_xc.trigger();
and
this.labels_xc.trigger();
setInterval(f, 30000);
function f( ) {
this.labels_xc.trigger();
Obviously I'm not putting this together correctly.
I appreciate your patience and help. -
Storing XML data in CLOB and relational tables
I would like to ask whether there is a possibility to store XML data using normal relational tables and CLOBs in the same time. For example I have some XML data (structured data) which I would like update very often and some which are only a kind of description. I found something about it in http://technet.oracle.com/tech/xml/infoocs/otnwp/about_oracle_xml_products.htm . But I do not know how to use Oracle8i views and some functionality of XML SQL Utility to retrieve XML data in one file.
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Maciej Marczukajtis ([email protected]):
I would like to ask whether there is a possibility to store XML data using normal relational tables and CLOBs in the same time. For example I have some XML data (structured data) which I would like update very often and some which are only a kind of description. I found something about it in http://technet.oracle.com/tech/xml/infoocs/otnwp/about_oracle_xml_products.htm . But I do not know how to use Oracle8i views and some functionality of XML SQL Utility to retrieve XML data in one file.<HR></BLOCKQUOTE>
Czesc Maciek,
There are some good examples with XSQL Servlet. From what I understand you have one XML file and you need to save a portion of document in relational tables and other portion in CLOB.
Yes, you can do that.
You can do it many ways. I can suggest (2).
1. Use the views
2. call your java procedure that will do
the xml processing, brake it down and insert
releval frogments into different tables/columns
null -
Using a SQL data source and XML data source in the same template
I am trying to develop a template for the Request for Quote report generated in Apps 11.5.10. I have loaded the data from the XML output into the template, but I am missing one field - I need the org_id from the po_headers table. Is it possible to use a sql data source (i.e., "select org_id from po_headers_all where po_header_id = [insert header_id from xml data]...") in addition to the xml data source to populate the template at runtime? When you use the Insert > SQL functionality is it static at the time the template is created, or does it call to the database at runtime? I've looked through all the docs I could find, but this isn't clear.
Thanks for any help or suggestions you may have.
RhondaHi Pablo
Thats a tough one ... if you go custom with a data template you will at least get support on the data template functionality ie you have a problem when you try and build one. You will not get support on the query inside the data template as you might have gotten with the Oracle Report, well you could at least log a bug against development for a bad query.
Eventually that Oracle Report will be converted by development anyway, theres an R12 project going on right now to switch the shipped OReports to data templates. AT this point you'll be fully supported again but:
1. You have to have R12 and
2. You'll need to wait for the patch
On reflection, if you are confident enough in the query then Oracle will support you on its implementation within a data template. Going forward you may be able to swap out your DT and out in the Oracle one without too much effort.
Regards, Tim
Maybe you are looking for
-
Sent messages from secondary account are not saved in Outlook 2011 for Mac
We are using a shared email account added in Outlook 2011 for Mac. It's not the default account but we send from it often. Whenever sending from this secondary mailbox, the message is not saved in sent items folder under the secondary mailbox or the
-
I transfered all my games from my iphone4s to my ipad, but the game progress is lost.... I signed on to game centre it shows all my scores and progress but when i try to play with the games, all my progress and scores disappears... can anyone help???
-
Hi, I am running Weblogic 6.1 sp1 and I am having a problem with import page directive. <%@ page import="my.package.*" %> does not appear to be working correctly when I try to reference classes in imported packages (my.p
-
HT2534 In Payment type None option is not available...
In my payment type screen, "NONE" option is not available.... I have only three types, "1.VISA, 2.Master Card, 3. AMEX".... I dnt want to register with my credit card detail.... I want use only free applications..... Can any one help me in this.....?
-
Agent Desktop can not be logging
I have this problem: After placing the credentials of the agent and passes connecting to the Cisco UCCX, get the error message: There has timed out the request for connection to Cisco UCCX application server, verify that the system is online and try