A problem extracting xmltype parameter
Hello
I'm using oracle 11g and I'm trying to use a xmltype as an input parameter to a SP, here is my SP:
create or replace PROCEDURE ABC
( FE_Param IN XMLType)
AS
BEGIN
FOR i IN
SELECT XMLTYPE.EXTRACT (VALUE (a),
'/Root/FE_ID/text()').getstringval() AS FE_ID
FROM TABLE
(XMLSEQUENCE (FE_Param.EXTRACT
('/FEData/Root')
) ) a )
LOOP
INSERT INTO table1
VALUES (i.FE_ID);
END LOOP;
The XML parameter looks like that:
<?xml version='1.0' encoding='utf-8' ?>
<FEData>
<Root><FE_ID>900000031</FE_ID>
<FE_ID>900000032</FE_ID><FE_ID>900000050</FE_ID></Root></FEData>
WITH table1 AS
(SELECT xmltype('<?xml version="1.0" encoding="utf-8" ?>
<FEData>
<Root>
<FE_ID>900000031</FE_ID>
<FE_ID>900000032</FE_ID>
<FE_ID>900000050</FE_ID>
</Root>
</FEData>'
) xmlcol FROM dual)
SELECT ExtractValue(column_Value, '/FE_ID').getStringVal() AS "FE_ID"
FROM table1 t1
, TABLE(xmlsequence(EXTRACT(t1.xmlcol,'/FEData/Root/FE_ID'))) v;
FE_ID
900000031
900000032
900000050
WITH table1 AS
(SELECT xmltype('<?xml version="1.0" encoding="utf-8" ?>
<FEData>
<Root>
<FE_ID>900000031</FE_ID>
<FE_ID>900000032</FE_ID>
<FE_ID>900000050</FE_ID>
</Root>
</FEData>'
) xmlcol FROM dual)
SELECT CAST(ExtractValue(column_Value, '/FE_ID') as VARCHAR2(10)) AS "FE_ID"
FROM table1 t1
, TABLE(xmlsequence(EXTRACT(t1.xmlcol,'/FEData/Root/FE_ID'))) v;
FE_ID
900000031
900000032
900000050 You should use XMLCAST by the way (something I don't have on my 10.2.x database). Also use the XMLTABLE format if your on Oracle 11g
Edited by: Marco Gralike on Aug 22, 2011 5:57 PM
Similar Messages
-
Problem converting XMLTYPE data into database rows.
Can anyone help with this ?
I�ve got an XML document like the following:
<ROWSET><ROW>><NAME>John</NAME></ROW></ROWSET>
I want to extract the �Name� element and insert it into a table that has one column:
create table employee
(empname varchar2(50));
The following PL/SQL block does the job:
begin
insert into employee
(empname)
select extractvalue(value(xmltab),'/ROW/NAME')
from table(xmlsequence(extract(xmltype('
<ROWSET><ROW>><NAME>Cpty 1</NAME></ROW></ROWSET>')
,'/ROWSET/ROW'))) xmltab;
commit;
end;
However, instead of having the XML string embedded in the actual SQL statement I would like to assign the XML string to a variable (of type XMLTYPE) and refer to the variable in the SQL statement i.e.
declare
v_xml xmltype;
begin
v_xml := xmltype(�<ROWSET><ROW>><NAME>John</NAME></ROW></ROWSET>�)
insert into employee
(empname)
select extractvalue(value(xmltab),'/ROW/NAME')
from table(xmlsequence(extract(v_xml,'/ROWSET/ROW'))) xmltab;
commit;
end;
When I run this I get the following exception:
ORA-22905 Cannot access rows from a non-nested table.
I can�t understand why the first example works but the second example doesn�t. I want to get the second version working because eventually I want to put this code in a stored proc that excepts an xmltype parameter.
Any help would be much appreciated.Hi
Now I understand why you want to use an insert as select...
The following PL/SQL code should work...
declare
v_xml xmltype;
begin
v_xml := xmltype('<ROWSET><ROW><NAME>John</NAME></ROW></ROWSET>');
insert into employee (empname)
select extractvalue(value(t),'/NAME')
from table(cast(xmlsequence(extract(v_xml, '/ROWSET/ROW/NAME'))as xmlsequencetype)) t;
commit;
end;
Chris -
Problem in getting parameter value from selection screen in web dynpro abap
Hi,
I am facing problem in getting parameter value from selection screen.
Please find my code below:
DATA LT_PAR_ITEM TYPE IF_WD_SELECT_OPTIONS=>TT_SELECTION_SCREEN_ITEM.
FIELD-SYMBOLS:<FS_PAR_ITEM> LIKE LINE OF LT_PAR_ITEM,
<FS_OBJ_USAGE> TYPE REF TO data.
WD_THIS->M_HANDLER->GET_PARAMETER_FIELDS( IMPORTING ET_FIELDS = LT_PAR_ITEM ).
LOOP AT LT_PAR_ITEM ASSIGNING <FS_PAR_ITEM>.
CASE <FS_PAR_ITEM>-M_ID.
WHEN `OBJ_USAGE`.
ASSIGN <FS_PAR_ITEM>-M_VALUE->* TO <FS_OBJ_USAGE>.
[ Here, sy-subrc is 4, <FS_OBJ_USAGE> is not assigning.]
ENDCASE.
ENDLOOP.
So, can any one solve this problem.
Thanks in advance,
RadhikaHi Radhika,
Try using GET_RANGE_TABLE_OF_SEL_FIELD...
Please Refer below code..
DATA: NODE_FLIGHTS TYPE REF TO IF_WD_CONTEXT_NODE.
DATA: RT_CARRID TYPE REF TO DATA.
DATA: ISFLIGHT TYPE TABLE OF SFLIGHT.
DATA: WSFLIGHT TYPE SFLIGHT.
FIELD-SYMBOLS: <FS_CARRID> TYPE TABLE.
Retrieve the data from the select option
RT_CARRID = WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD( I_ID = 'S_CARR_ID' ).
Assign it to a field symbol
ASSIGN RT_CARRID->* TO <FS_CARRID>.
CLEAR ISFLIGHT. REFRESH ISFLIGHT.
SELECT * INTO CORRESPONDING FIELDS OF TABLE ISFLIGHT FROM SFLIGHT
WHERE CARRID IN <FS_CARRID>.
NODE_FLIGHTS = WD_CONTEXT->GET_CHILD_NODE( NAME = `FLIGHTS` ).
NODE_FLIGHTS->BIND_ELEMENTS( ISFLIGHT ).
Thanks,
Regards,
Kiran -
Problems Extracting Raw off 5d Mk2 with PSE7 on Windows 7
Hi
Anyone had any problems extracting the RAW photos off a 5dmk2 camera using PSE7 on Windows 7.
Basically, the problem occurs when the the camera has Raw files on aswell as jpegs. When I select the option to get files from camera or card reader, I can select the device and then the camera is analysed and the number of files counted. Fine. However, if I then press Get Photo's the window kind of freezes, nothing happens and the window can't be closed. If there are just jpegs on the camera then there's not a problem but I want to be able to use Raws.
It works fine on Windows XP SP3 with Raw plugin 5.4.
I've tried all the raw plugins I can up until the latest one that is suitable (v5.6).
I'm not confusing the 32bit or 64bit versions.
I'm following the exact instructions on installing the raw plugin's properly.
I've tried all sorts of different settings in Windows compatibility mode.
I've run as the administrator.
I've read numerous posts to see what solutions people have to related but not identical problems.
I don't want to process it separately and turn it into a company's own file format first (forgotten what it was), I just want to use the Raw files in the same way that they worked on Windows XP.
Don't know what else to try.......
Can anyone please help?
Thanks in advance.....Ok.... I've got a work around but there's a definite bug here..... not sure why this should happen.
Basically, the only way I can extract the raws off the camera is to import a new raw from a folder i.e. 'File > Get
Photos > From Files or Folders'.
Then if I go to 'File > Get Photos > From Camera or Card Reader' everything works as it should, the files get extracted
from the camera.
Assumed it would be working ok permenantly after having to do that yesterday, but couldn't get raws off again without
repeating the steps above......
....wierd....it's almost like it needs reminding that it can handle raws before extracting.....
I know someone on another blog said they had the same set up and didn't have a problem, but I wonder if it's something
subtle in the differences between our base system setup......
Anyway hope this helps give people a work around if they encounter the same issue?
If anyone has a permenant solution please let me know as I don't want to have to rename and then reimport a raw file
everytime I extract photos...... -
Problem Extracting Still Image, FCP 5.1.1
I'm having a problem extracting a still image from a clip in FCP 5.1.1 I am using a Macbook Pro and editing HDV1080i60 captured from a Sony HVR-Z1U. I recently upgraded to QuickTime 7.1.1, and since I had no problem extracting stills at one point before this I wonder if QuickTime integration might be part of the problem. The problem is that as soon as I select "extract quicktime conversion" from the file > extract menu, the frame in the canvas jumps to something else besides the frame it was on that I wanted to capture. Sometimes it jumps a few frames to one close to the one I wanted, but one time it jumped all the way to the beginning of the clip. This new frame is the one it ends up capturing. Furthermore, when I then open this image in quicktime it is displayed as a distorted picture that has been compressed into a 4:3 image instead of the proper 16:9 size.
Any help with what might be going on here would be greatly appreciated.Thanks for your reply. I have recently discovered that the issue of FCP jumping to another frame than the one I wanted to capture has to do with a setting on the camera that I used when shooting. (The footage was shot using a reduced frame rate setting option on the camera). The more important issue now is that the exported image that I get, even though it is the right one, is squeezed into a 4:3 size, distorting everything in it. Any ideas on this? Everything worked fine before I upgraded to the new version of QuickTime, and I can't help but think there might be a bug in the new version or something. But maybe theres something I have set wrong?
-
Hi,
We are having problem extracting LIS data.
I have cheked the delta queue (RSA7), and 2LIS_13_VDITM has total 0.
I have also checked transaction LBWQ, and can see that the MCEX13 has got 150028 entries and MCEX11 has got 12811 entries in the queue. It has destination NONE and status NOSEND.
What can I do to transfer all these entries to the delta queue so that they can be loaded to BW?
BR,
LindaHi Linda,
search form RMBWV in the ABAP input box (job name = *, user = *)
goto SMQ1 in the source system; you'll see LUWs for the MCEX* queue.
in this tran you also see your BW delta queue; do you see LUWs as well for your datasource?
you can schedule the update job via LBWE / job control; once executed, the LUWs for MCEX* should decrease and your BW LUWs should incerease...
let us know
hope this helps
Olivier.
Message was edited by:
Olivier Cora -
Problems extracting Lightroom5_6 upgrade files after download
Hello!
I've just completed installing a LR5 upgrade from a DVD disc.
After this, I downloaded the latest update which in this case was Lightroom 5.6.
My problem is that I am now unable to extract the downloaded update files.
I just get a message from the installer telling me that there is a problem extracting some files and to check that there is enough memory on my computer. The message also suggest to check that I am authourized to use the target folder for the extraction.
I've reinstalled LR5, I've tryed downloading a new update folder several times, I've tryed extracting it in different folders.
There is enough memory and my computer system meets the requirements. (I'am the administrator of course.)
Anybody has a solution?
Thanks in advance!
Felix
PS below is an image of the message I get when trying to extract files (in swedish though).Hej Dave,
And thanks for your tips!
I've actually tryed both the update 5,5 and the 5,6 with the same result and the screenshot just happened to be for 5,5.
I've now also tryed extracting the the updatefile using both winrar and winzip but the problem is that it is an exe-file (program file).
So no luck there and I dont know of any software that "extracts" / unfolds a program file. Do you know of any such software?
Thanks anyway
Felix -
Problems extracting LR5.6 upgrade files after download
Hello!
I've just completed installing a LR5 upgrade from a DVD.
After this, I downloaded the latest upgrade which i this case was is LR5.6.
My problem is that I am unable to extract the files in the upgrade.
I just get a message from the installer telling me that there is a problem extracting some files and to check that there is enough memory on my computer. The message also suggest to check that I am authourized to use the target folder for the extraction.
I've reinstalled LR5, I've tryed downloading a new upgradefolder several times, I've tryed extracting it in different folders.
There is enough memory and my computer system meets the requirements. (I'am the administrator of course.)
Anybody has a solution?
Thanks in advance!
Felix
PS below is an image of the message I get when trying to extract files (in swedish though).Hello Jeff!
And thanks for your answer.
Yes i've tried extracting/installing both updates (5.5 and 5.6). The outcome was the same in both cases. Same message with 5.6 as the one in my screenshot.
There is some information in this but I can't figure out what it is.
Felix
Skickat från min iPhone
29 aug 2014 kl. 22:50 skrev Jeff A Wright <[email protected]>:
Problems extracting LR5.6 upgrade files after download
created by Jeff A Wright in Downloading, Installing, Setting Up - View the full discussion
Felix2 from your screen shot it appears you are attempting to download and extract the Lightroom 5.5 update/installer. Do you receive the same error downloading the 5.6 update at Adobe - Lightroom : For Windows : Adobe Photoshop Lightroom 5.6? Each update contains the full installer so you do not need to have a previous version of Lightroom installed prior to installing Photoshop Lightroom 5.6.
Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6685604#6685604
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Downloading, Installing, Setting Up by email or at Adobe Community
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0. -
Database Native Web Services : XMLTYPE parameter in PL/SQL with XMLSCHEMA?
Hi,
I would like to build a function with a XMLTYPE parameter which is schema based, something like this:
CREATE FUNCTION xy (p_xml XMLTYPE XMLSCHEMA 'http://myschema.com') ...
At the moment I do the following inside the code:
l_xml := p_xml.createSchemaBasedXML('http://myschema.com');
l_xml.schemavalidate();
/* validate XML against XSD */
l_nbr := l_xml.isschemavalidated();
The purpose why I would like to directly put the schema in the declaration is that I would like to use this function as a Oracle Native Web Service. The web service doesn't know the structure of the xml parameter as the schema is not knows in the declaration.
Thanks and kind regards,
Andreas
Edited by: mdrake on Nov 8, 2009 9:55 PMJust for kicks here's the best I can come up with..
SQL> connect &USERNAME/&PASSWORD
Connected.
SQL> --
SQL> --
SQL> --
SQL> declare
2 XMLSCHEMA XMLTYPE := XMLTYPE(
3 '<!-- edited with XML Spy v4.0 U (http://www.xmlspy.com) by Mark (Drake) -->
4 <xs:schema targetNamespace="http://xmlns.example.com/xsd/purchaseOrder"
5 xmlns="http://xmlns.example.com/xsd/purchaseOrder"
6 xmlns:xs="http://www.w3.org/2001/XMLSchema"
7 xmlns:xdb="http://xmlns.oracle.com/xdb" version="1.0" xdb:storeVarrayAsTable="true">
8 <xs:element name="PurchaseOrder" type="PurchaseOrderType" xdb:defaultTable="PURCHASEORDER"/>
9 <xs:complexType name="PurchaseOrderType" xdb:SQLType="PURCHASEORDER_T">
10 <xs:sequence>
11 <xs:element name="Reference" type="ReferenceType" xdb:SQLName="REFERENCE"/>
12 <xs:element name="Actions" type="ActionsType" xdb:SQLName="ACTIONS"/>
13 <xs:element name="Reject" type="RejectionType" minOccurs="0" xdb:SQLName="REJECTION"/>
14 <xs:element name="Requestor" type="RequestorType" xdb:SQLName="REQUESTOR"/>
15 <xs:element name="User" type="UserType" xdb:SQLName="USERID"/>
16 <xs:element name="CostCenter" type="CostCenterType" xdb:SQLName="COST_CENTER"/>
17 <xs:element name="ShippingInstructions" type="ShippingInstructionsType" xdb:SQLName="SHIPPING_INSTRUCTIONS"/>
18 <xs:element name="SpecialInstructions" type="SpecialInstructionsType" xdb:SQLName="SPECIAL_INSTRUCTIONS"/>
19 <xs:element name="LineItems" type="LineItemsType" xdb:SQLName="LINEITEMS"/>
20 </xs:sequence>
21 </xs:complexType>
22 <xs:complexType name="LineItemsType" xdb:SQLType="LINEITEMS_T">
23 <xs:sequence>
24 <xs:element name="LineItem" type="LineItemType" maxOccurs="unbounded" xdb:SQLName="LINEITEM" xdb:SQLCollType="LINEITEM_V"/>
25 </xs:sequence>
26 </xs:complexType>
27 <xs:complexType name="LineItemType" xdb:SQLType="LINEITEM_T">
28 <xs:sequence>
29 <xs:element name="Description" type="DescriptionType" xdb:SQLName="DESCRIPTION"/>
30 <xs:element name="Part" type="PartType" xdb:SQLName="PART"/>
31 </xs:sequence>
32 <xs:attribute name="ItemNumber" type="xs:integer" xdb:SQLName="ITEMNUMBER" xdb:SQLType="NUMBER"/>
33 </xs:complexType>
34 <xs:complexType name="PartType" xdb:SQLType="PART_T">
35 <xs:attribute name="Id" xdb:SQLName="PART_NUMBER" xdb:SQLType="VARCHAR2">
36 <xs:simpleType>
37 <xs:restriction base="xs:string">
38 <xs:minLength value="10"/>
39 <xs:maxLength value="14"/>
40 </xs:restriction>
41 </xs:simpleType>
42 </xs:attribute>
43 <xs:attribute name="Quantity" type="moneyType" xdb:SQLName="QUANTITY"/>
44 <xs:attribute name="UnitPrice" type="quantityType" xdb:SQLName="UNITPRICE"/>
45 </xs:complexType>
46 <xs:simpleType name="ReferenceType">
47 <xs:restriction base="xs:string">
48 <xs:minLength value="18"/>
49 <xs:maxLength value="30"/>
50 </xs:restriction>
51 </xs:simpleType>
52 <xs:complexType name="ActionsType" xdb:SQLType="ACTIONS_T">
53 <xs:sequence>
54 <xs:element name="Action" maxOccurs="4" xdb:SQLName="ACTION" xdb:SQLCollType="ACTION_V">
55 <xs:complexType xdb:SQLType="ACTION_T">
56 <xs:sequence>
57 <xs:element name="User" type="UserType" xdb:SQLName="ACTIONED_BY"/>
58 <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_ACTIONED"/>
59 </xs:sequence>
60 </xs:complexType>
61 </xs:element>
62 </xs:sequence>
63 </xs:complexType>
64 <xs:complexType name="RejectionType" xdb:SQLType="REJECTION_T">
65 <xs:all>
66 <xs:element name="User" type="UserType" minOccurs="0" xdb:SQLName="REJECTED_BY"/>
67 <xs:element name="Date" type="DateType" minOccurs="0" xdb:SQLName="DATE_REJECTED"/>
68 <xs:element name="Comments" type="CommentsType" minOccurs="0" xdb:SQLName="REASON_REJECTED"/>
69 </xs:all>
70 </xs:complexType>
71 <xs:complexType name="ShippingInstructionsType" xdb:SQLType="SHIPPING_INSTRUCTIONS_T">
72 <xs:sequence>
73 <xs:element name="name" type="NameType" minOccurs="0" xdb:SQLName="SHIP_TO_NAME"/>
74 <xs:element name="address" type="AddressType" minOccurs="0" xdb:SQLName="SHIP_TO_ADDRESS"/>
75 <xs:element name="telephone" type="TelephoneType" minOccurs="0" xdb:SQLName="SHIP_TO_PHONE"/>
76 </xs:sequence>
77 </xs:complexType>
78 <xs:simpleType name="moneyType">
79 <xs:restriction base="xs:decimal">
80 <xs:fractionDigits value="2"/>
81 <xs:totalDigits value="12"/>
82 </xs:restriction>
83 </xs:simpleType>
84 <xs:simpleType name="quantityType">
85 <xs:restriction base="xs:decimal">
86 <xs:fractionDigits value="4"/>
87 <xs:totalDigits value="8"/>
88 </xs:restriction>
89 </xs:simpleType>
90 <xs:simpleType name="UserType">
91 <xs:restriction base="xs:string">
92 <xs:minLength value="1"/>
93 <xs:maxLength value="10"/>
94 </xs:restriction>
95 </xs:simpleType>
96 <xs:simpleType name="RequestorType">
97 <xs:restriction base="xs:string">
98 <xs:minLength value="0"/>
99 <xs:maxLength value="128"/>
100 </xs:restriction>
101 </xs:simpleType>
102 <xs:simpleType name="CostCenterType">
103 <xs:restriction base="xs:string">
104 <xs:minLength value="1"/>
105 <xs:maxLength value="4"/>
106 </xs:restriction>
107 </xs:simpleType>
108 <xs:simpleType name="VendorType">
109 <xs:restriction base="xs:string">
110 <xs:minLength value="0"/>
111 <xs:maxLength value="20"/>
112 </xs:restriction>
113 </xs:simpleType>
114 <xs:simpleType name="PurchaseOrderNumberType">
115 <xs:restriction base="xs:integer"/>
116 </xs:simpleType>
117 <xs:simpleType name="SpecialInstructionsType">
118 <xs:restriction base="xs:string">
119 <xs:minLength value="0"/>
120 <xs:maxLength value="2048"/>
121 </xs:restriction>
122 </xs:simpleType>
123 <xs:simpleType name="NameType">
124 <xs:restriction base="xs:string">
125 <xs:minLength value="1"/>
126 <xs:maxLength value="20"/>
127 </xs:restriction>
128 </xs:simpleType>
129 <xs:simpleType name="AddressType">
130 <xs:restriction base="xs:string">
131 <xs:minLength value="1"/>
132 <xs:maxLength value="256"/>
133 </xs:restriction>
134 </xs:simpleType>
135 <xs:simpleType name="TelephoneType">
136 <xs:restriction base="xs:string">
137 <xs:minLength value="1"/>
138 <xs:maxLength value="24"/>
139 </xs:restriction>
140 </xs:simpleType>
141 <xs:simpleType name="DateType">
142 <xs:restriction base="xs:date"/>
143 </xs:simpleType>
144 <xs:simpleType name="CommentsType">
145 <xs:restriction base="xs:string">
146 <xs:minLength value="1"/>
147 <xs:maxLength value="2048"/>
148 </xs:restriction>
149 </xs:simpleType>
150 <xs:simpleType name="DescriptionType">
151 <xs:restriction base="xs:string">
152 <xs:minLength value="1"/>
153 <xs:maxLength value="256"/>
154 </xs:restriction>
155 </xs:simpleType>
156 </xs:schema>');
157 begin
158 dbms_xmlschema.registerSchema( SCHEMAURL => '/xsd/purchaseOrder.xsd', SCHEMADOC => XMLSCHEMA);
159 end;
160 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.94
SQL> VAR URL VARCHAR2(1024)
SQL> VAR RESULT CLOB;
SQL> --
SQL> create or replace package TESTPROC
2 as
3 function getPurchaseOrder(P_REFERENCE VARCHAR2) return XMLTYPE;
4 function expandWSDL return XMLTYPE;
5 end;
6 /
Package created.
Elapsed: 00:00:00.02
SQL> --
SQL> create or replace package body TESTPROC
2 as
3 --
4 function getPurchaseOrder(P_REFERENCE VARCHAR2)
5 return XMLType
6 as
7 V_RESULT XMLTYPE;
8 begin
9 select object_value
10 into V_RESULT
11 from PURCHASEORDER
12 where XMLEXISTS('$p/PurchaseOrder[Reference=$ref]' passing P_REFERENCE as "ref");
13 return V_RESULT;
14 end;
15 --
16 function getWSDL
17 return XMLType
18 as
19 V_WSDL_URL VARCHAR2(700) := 'http://&USERNAME:&PASSWORD@localhost:' || dbms_xdb.getHttpPort() || '/orawsv/&USERNAME/TESTPROC/GETPURCHASEORDER';
20 V_WSDL XMLTYPE;
21 begin
22 select httpuritype( V_WSDL_URL || '?wsdl' ).getXML()
23 into V_WSDL
24 from dual;
25 return V_WSDL;
26 end;
27 --
28 function expandWSDL
29 return XMLTYPE
30 as
31 V_INTERNAL_URL VARCHAR2(700);
32 V_EXTERNAL_URL VARCHAR2(700);
33 V_NAMESPACE VARCHAR2(4000);
34 V_WSDL XMLTYPE := getWSDL();
35 V_XSD XMLTYPE;
36 begin
37 -- Need to provide real logic to determine which XSD goes with which parameter...
38
39 -- get the TARGETNAMESPACE for the import element (Not sure how this would work with a noNamespace Schema since we'd be in Chamelian Land)
40 select SCHEMA_URL,
41 XMLCAST
42 (
43 XMLQUERY
44 (
45 'declare namespace xsd = "http://www.w3.org/2001/XMLSchema"; (::)
46 $xsd/xsd:schema/@targetNamespace'
47 passing SCHEMA as "xsd" returning content
48 )
49 as VARCHAR2(4000)
50 )
51 into V_INTERNAL_URL, V_NAMESPACE
52 from USER_XML_SCHEMAS
53 where SCHEMA_URL = '/xsd/purchaseOrder.xsd';
54
55 V_EXTERNAL_URL := '/sys/schemas/&USERNAME' || V_INTERNAL_URL;
56
57 -- Add <xsd:import namespace="http://xmlns.example.com/xsd/purchaseOrder" schemaLocation="http://localhost:80/sys/schemas/WSDLTEST/xsd/purchaseOrder.xsd
"/>
58
59 select insertXMLBefore
60 (
61 V_WSDL,
62 '//xsd:schema/child::*[1]',
63 xmlElement("xsd:import",xmlAttributes('http://www.w3.org/2001/XMLSchema' as "xmlns:xsd",V_NAMESPACE as "namespace",V_EXTERNAL_URL as "schemaLoc
ation")),
64 'xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
65 )
66 into V_WSDL
67 from dual;
68
69 select updateXML
70 (
71 V_WSDL,
72 '//xsd:schema/xsd:element[@name="GETPURCHASEORDEROutput"]/xsd:complexType/xsd:sequence/xsd:element[@name="RETURN"]/xsd:complexType',
73 XMLElement
74 (
75 "xsd:complexType",
76 XMLAttributes('http://www.w3.org/2001/XMLSchema' as "xmlns:xsd"),
77 XMLElement
78 (
79 "xsd:sequence",
80 XMLElement
81 (
82 "xsd:element",
83 xmlAttributes('http://xmlns.example.com/xsd/purchaseOrder' as "xmlns:po",'po:PurchaseOrder' as "ref")
84 )
85 )
86 ),
87 'xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
88 )
89 into V_WSDL
90 from dual;
91
92 return V_WSDL;
93 end;
94 --
95 end;
96 /
old 19: V_WSDL_URL VARCHAR2(700) := 'http://&USERNAME:&PASSWORD@localhost:' || dbms_xdb.getHttpPort() || '/orawsv/&USERNAME/TESTPROC/GETPURCHASEORDER';
new 19: V_WSDL_URL VARCHAR2(700) := 'http://WSDLTEST:WSDLTEST@localhost:' || dbms_xdb.getHttpPort() || '/orawsv/WSDLTEST/TESTPROC/GETPURCHASEORDER';
old 55: V_EXTERNAL_URL := '/sys/schemas/&USERNAME' || V_INTERNAL_URL;
new 55: V_EXTERNAL_URL := '/sys/schemas/WSDLTEST' || V_INTERNAL_URL;
Package body created.
Elapsed: 00:00:00.05
SQL> show errors
No errors.
SQL> --
SQL> BEGIN
2 :URL := 'http://&USERNAME:&PASSWORD@localhost:' || dbms_xdb.getHttpPort() || '/orawsv/&USERNAME/TESTPROC';
3 end;
4 /
old 2: :URL := 'http://&USERNAME:&PASSWORD@localhost:' || dbms_xdb.getHttpPort() || '/orawsv/&USERNAME/TESTPROC';
new 2: :URL := 'http://WSDLTEST:WSDLTEST@localhost:' || dbms_xdb.getHttpPort() || '/orawsv/WSDLTEST/TESTPROC';
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
SQL> print url
URL
http://WSDLTEST:WSDLTEST@localhost:80/orawsv/WSDLTEST/TESTPROC
SQL> --
SQL> set long 10000000 pages 0 lines 160
SQL> --
SQL> select httpuritype( :URL || '?wsdl' ).getXML()
2 from dual
3 /
<definitions name="TESTPROC" targetNamespace="http://xmlns.oracle.com/orawsv/WSDLTEST/TESTPROC" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xmlns
.oracle.com/orawsv/WSDLTEST/TESTPROC" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/WSDLTEST/TESTPROC" elementFormDefault="qualified">
<xsd:element name="CXMLTYPE-GETPURCHASEORDERInput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="P_REFERENCE-VARCHAR2-IN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GETPURCHASEORDEROutput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RETURN">
<xsd:complexType>
<xsd:sequence>
<xsd:any/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="CXMLTYPE-EXPANDWSDLInput">
<xsd:complexType>
<xsd:sequence>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="EXPANDWSDLOutput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RETURN">
<xsd:complexType>
<xsd:sequence>
<xsd:any/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="GETPURCHASEORDERInputMessage">
<part name="parameters" element="tns:CXMLTYPE-GETPURCHASEORDERInput"/>
</message>
<message name="GETPURCHASEORDEROutputMessage">
<part name="parameters" element="tns:GETPURCHASEORDEROutput"/>
</message>
<message name="EXPANDWSDLInputMessage">
<part name="parameters" element="tns:CXMLTYPE-EXPANDWSDLInput"/>
</message>
<message name="EXPANDWSDLOutputMessage">
<part name="parameters" element="tns:EXPANDWSDLOutput"/>
</message>
<portType name="TESTPROCPortType">
<operation name="GETPURCHASEORDER">
<input message="tns:GETPURCHASEORDERInputMessage"/>
<output message="tns:GETPURCHASEORDEROutputMessage"/>
</operation>
<operation name="EXPANDWSDL">
<input message="tns:EXPANDWSDLInputMessage"/>
<output message="tns:EXPANDWSDLOutputMessage"/>
</operation>
</portType>
<binding name="TESTPROCBinding" type="tns:TESTPROCPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GETPURCHASEORDER">
<soap:operation soapAction="GETPURCHASEORDER"/>
<input>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body parts="parameters" use="literal"/>
</output>
</operation>
<operation name="EXPANDWSDL">
<soap:operation soapAction="EXPANDWSDL"/>
<input>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body parts="parameters" use="literal"/>
</output>
</operation>
</binding>
<service name="TESTPROCService">
<documentation>Oracle Web Service</documentation>
<port name="TESTPROCPort" binding="tns:TESTPROCBinding">
<soap:address location="http://localhost:80/orawsv/WSDLTEST/TESTPROC"/>
</port>
</service>
</definitions>
Elapsed: 00:00:00.33
SQL> select TESTPROC.expandWSDL()
2 from dual
3 /
<definitions name="GETPURCHASEORDER" targetNamespace="http://xmlns.oracle.com/orawsv/WSDLTEST/TESTPROC/GETPURCHASEORDER" xmlns="http://schemas.xmlsoap.org/wsdl/
" xmlns:tns="http://xmlns.oracle.com/orawsv/WSDLTEST/TESTPROC/GETPURCHASEORDER" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.
org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/WSDLTEST/TESTPROC/GETPURCHASEORDER" elementFormDefault="qualified">
<xsd:import xmlns:xsd="http://www.w3.org/2001/XMLSchema" namespace="http://xmlns.example.com/xsd/purchaseOrder" schemaLocation="/sys/schemas/WSDLTEST/xsd/
purchaseOrder.xsd"/>
<xsd:element name="CXMLTYPE-GETPURCHASEORDERInput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="P_REFERENCE-VARCHAR2-IN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GETPURCHASEORDEROutput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RETURN">
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:sequence>
<xsd:element xmlns:po="http://xmlns.example.com/xsd/purchaseOrder" ref="po:PurchaseOrder"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="GETPURCHASEORDERInputMessage">
<part name="parameters" element="tns:CXMLTYPE-GETPURCHASEORDERInput"/>
</message>
<message name="GETPURCHASEORDEROutputMessage">
<part name="parameters" element="tns:GETPURCHASEORDEROutput"/>
</message>
<portType name="GETPURCHASEORDERPortType">
<operation name="GETPURCHASEORDER">
<input message="tns:GETPURCHASEORDERInputMessage"/>
<output message="tns:GETPURCHASEORDEROutputMessage"/>
</operation>
</portType>
<binding name="GETPURCHASEORDERBinding" type="tns:GETPURCHASEORDERPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GETPURCHASEORDER">
<soap:operation soapAction="GETPURCHASEORDER"/>
<input>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body parts="parameters" use="literal"/>
</output>
</operation>
</binding>
<service name="GETPURCHASEORDERService">
<documentation>Oracle Web Service</documentation>
<port name="GETPURCHASEORDERPort" binding="tns:GETPURCHASEORDERBinding">
<soap:address location="http://localhost:80/orawsv/WSDLTEST/TESTPROC/GETPURCHASEORDER"/>
</port>
</service>
</definitions>
Elapsed: 00:00:00.11
SQL> BEGIN
2 :URL := 'http://&USERNAME:&PASSWORD@localhost:' || dbms_xdb.getHttpPort() || '/orawsv/&USERNAME/TESTPROC/EXPANDWSDL';
3 end;
4 /
old 2: :URL := 'http://&USERNAME:&PASSWORD@localhost:' || dbms_xdb.getHttpPort() || '/orawsv/&USERNAME/TESTPROC/EXPANDWSDL';
new 2: :URL := 'http://WSDLTEST:WSDLTEST@localhost:' || dbms_xdb.getHttpPort() || '/orawsv/WSDLTEST/TESTPROC/EXPANDWSDL';
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
SQL> print url
http://WSDLTEST:WSDLTEST@localhost:80/orawsv/WSDLTEST/TESTPROC/EXPANDWSDL
SQL> --
SQL> set serveroutput on
SQL> --
SQL> VAR WSDL_TEXT CLOB
SQL> --
SQL> DECLARE
2 V_SOAP_REQUEST XMLTYPE := XMLTYPE(
3 '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
4 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
7 <SOAP-ENV:Body>
8 <m:CXMLTYPE-EXPANDWSDLInput xmlns:m="http://xmlns.oracle.com/orawsv/WSDLTEST/TESTPROC"/>
9 </SOAP-ENV:Body>
10 </SOAP-ENV:Envelope>');
11 V_SOAP_REQUEST_TEXT CLOB := V_SOAP_REQUEST.getClobVal();
12 V_REQUEST UTL_HTTP.REQ;
13 V_RESPONSE UTL_HTTP.RESP;
14 V_BUFFER VARCHAR2(1024);
15 V_RESPONSE_TEXT CLOB;
16 V_RESPONSE_XML XMLTYPE;
17 V_WSDL XMLTYPE;
18 BEGIN
19 DBMS_LOB.CREATETEMPORARY(V_RESPONSE_TEXT, TRUE);
20
21 begin
22 V_REQUEST := UTL_HTTP.BEGIN_REQUEST(URL => :URL, METHOD => 'POST');
23 UTL_HTTP.SET_HEADER(V_REQUEST, 'User-Agent', 'Mozilla/4.0');
24 V_REQUEST.METHOD := 'POST';
25 UTL_HTTP.SET_HEADER (R => V_REQUEST, NAME => 'Content-Length', VALUE => DBMS_LOB.GETLENGTH(V_SOAP_REQUEST_TEXT));
26 UTL_HTTP.WRITE_TEXT (R => V_REQUEST, DATA => V_SOAP_REQUEST_TEXT);
27 V_RESPONSE := UTL_HTTP.GET_RESPONSE(V_REQUEST);
28 LOOP
29 UTL_HTTP.READ_LINE(V_RESPONSE, V_BUFFER, TRUE);
30 DBMS_LOB.WRITEAPPEND(V_RESPONSE_TEXT,LENGTH(V_BUFFER),V_BUFFER);
31 END LOOP;
32 UTL_HTTP.END_RESPONSE(V_RESPONSE);
33 EXCEPTION
34 WHEN UTL_HTTP.END_OF_BODY THEN
35 UTL_HTTP.END_RESPONSE(V_RESPONSE);
36 END;
37
38 V_RESPONSE_XML := XMLTYPE(V_RESPONSE_TEXT);
39
40 select XMLQUERY
41 (
42 'declare namespace SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; (::)
43 declare namespace SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"; (::)
44 declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance"; (::)
45 declare namespace xsd="http://www.w3.org/2001/XMLSchema"; (::)
46 declare namespace m="http://xmlns.oracle.com/orawsv/WSDLTEST/TESTPROC"; (::)
47 $resp/SOAP-ENV:Envelope/SOAP-ENV:Body/m:EXPANDWSDLOutput/m:RETURN/*'
48 passing V_RESPONSE_XML as "resp" returning content
49 )
50 into V_WSDL
51 from DUAL;
52
53 select V_WSDL.getClobVal()
54 into :WSDL_TEXT
55 from dual;
56
57 DBMS_LOB.FREETEMPORARY(V_RESPONSE_TEXT);
58
59 END;
60 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.10
SQL> --
SQL> set pages 0 lines 160 long 10000
SQL> column WSDL format A160
SQL> --
SQL> select xmlserialize(document XMLTYPE(:WSDL_TEXT) as CLOB indent size=2) WSDL
2 from dual
3 /
<definitions name="GETPURCHASEORDER" targetNamespace="http://xmlns.oracle.com/orawsv/WSDLTEST/TESTPROC/GETPURCHASEORDER" xmlns="http://schemas.xmlsoap.org/wsdl/
" xmlns:tns="http://xmlns.oracle.com/orawsv/WSDLTEST/TESTPROC/GETPURCHASEORDER" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.
org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/WSDLTEST/TESTPROC/GETPURCHASEORDER" elementFormDefault="qualified">
<xsd:import xmlns:xsd="http://www.w3.org/2001/XMLSchema" namespace="http://xmlns.example.com/xsd/purchaseOrder" schemaLocation="/sys/schemas/WSDLTEST/xsd/
purchaseOrder.xsd"/>
<xsd:element name="CXMLTYPE-GETPURCHASEORDERInput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="P_REFERENCE-VARCHAR2-IN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="GETPURCHASEORDEROutput">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RETURN">
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:sequence>
<xsd:element xmlns:po="http://xmlns.example.com/xsd/purchaseOrder" ref="po:PurchaseOrder"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="GETPURCHASEORDERInputMessage">
<part name="parameters" element="tns:CXMLTYPE-GETPURCHASEORDERInput"/>
</message>
<message name="GETPURCHASEORDEROutputMessage">
<part name="parameters" element="tns:GETPURCHASEORDEROutput"/>
</message>
<portType name="GETPURCHASEORDERPortType">
<operation name="GETPURCHASEORDER">
<input message="tns:GETPURCHASEORDERInputMessage"/>
<output message="tns:GETPURCHASEORDEROutputMessage"/>
</operation>
</portType>
<binding name="GETPURCHASEORDERBinding" type="tns:GETPURCHASEORDERPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GETPURCHASEORDER">
<soap:operation soapAction="GETPURCHASEORDER"/>
<input>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body parts="parameters" use="literal"/>
</output>
</operation>
</binding>
<service name="GETPURCHASEORDERService">
<documentation>Oracle Web Service</documentation>
<port name="GETPURCHASEORDERPort" binding="tns:GETPURCHASEORDERBinding">
<soap:address location="http://localhost:80/orawsv/WSDLTEST/TESTPROC/GETPURCHASEORDER"/>
</port>
</service>
</definitions>
Elapsed: 00:00:00.03
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
C:\xdb\examples\DBNWS> -
Problem extracting values from parameter...
Evening all,
I am struggling to extract the values for particular columns within a foreach loop, the code is as follows:
$Processor = Get-WmiObject -Class Win32_PerfFormattedData_PerfDisk_LogicalDisk | where {$_.name -like '*:*'} | Format-Table -AutoSize -Property Name , DiskReadBytesPersec, DiskWriteBytesPersec , FreeMegabytes , PercentFreeSpace
foreach($row in $Processor)
$Name = $row.Name
$Reads = $row.DiskReadBytesPersec
$Writes = $row.DiskWriteBytesPersec
$FreeMB = $row.FreeMegabytes
$FreeSpace = $row.PercentFreeSpace
When returning the value of the parameter, all the correct values are there with the correct column headers. This is probably something simple enough to resolve but no matter how I format it, I can't get it to work. A quick pointer in the right direction
would be really helpful.
CheersHi Ghostface,
this is due to your use of Format-Table. Format functions convert objects into something that the console can easily display to your screen, but datawise it's pretty much a dead end. Replace "Format-Table -AutoSize -Property" with "Select"
and you should be fine (And not need your loop either).
Cheers,
Fred
Ps.: You can rename properties with Select too. Compare these two lines:
Get-WmiObject -Class Win32_PerfFormattedData_PerfDisk_LogicalDisk | where {$_.name -like '*:*'} | Select Name, DiskReadBytesPersec
Get-WmiObject -Class Win32_PerfFormattedData_PerfDisk_LogicalDisk | where {$_.name -like '*:*'} | Select Name, @{ n = "RBPSec" ; e = { $_.DiskReadBytesPersec }}
PPs: Some more Select magic: Combined and calculated Values:
Get-WmiObject -Class Win32_PerfFormattedData_PerfDisk_LogicalDisk | where {$_.name -like '*:*'} | Select Name, DiskReadBytesPersec, DiskWriteBytesPersec, @{ n = "RWRatio"; e = {$_.DiskReadBytesPersec / $_.DiskWriteBytesPersec}}, FreeMegabytes, PercentFreeSpace, @{ n = "UsedMegabytes"; e = {$_.FreeMegabytes / $_.PercentFreeSpace * (100 - $_.PercentFreeSpace)}}
There's no place like 127.0.0.1 -
Problem extracting SOAP XML payload using pl/sql
Hi,
I was wondering if I could get some help on extracting the address matches that are returned from the Web Service I am consuming. This is the first time I have dealt with XML and web services. I'm using Oracle 10.2.0.1.
The response I’m getting back returns 4 address matches (shown below against n2, n4, n6 and n8) which is:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Header/><soapenv:Body><searchResponse
xmlns="http://ws.aplt.msi.com"><searchReturn><?xml version="1.0"
encoding="UTF-8" standalone="yes"?>
<GetAddressSearchResponse
xmlns="http://aplt.nzpost.co.nz/schemas/search">
<ns1:ResponseHeader
xmlns:ns1="http://aplt.nzpost.co.nz/schemas/common">
<ns1:Errors/>
</ns1:ResponseHeader>
<SearchResults SearchType="StreetAddress">
<ResultRecord Type="URBAN">
<ns2:AddressDetails
xmlns:ns2="urn:nzpost:schemas:xAL:3.0">
<ns2:Locality>
<ns2:Name>LOWER HUTT</ns2:Name>
<ns2:DependentLocality>
<ns2:Name>WAINUIOMATA</ns2:Name>
</ns2:DependentLocality>
</ns2:Locality>
<ns2:Thoroughfare>
<ns2:Name>MAIN ROAD</ns2:Name>
<ns2:Number>
<ns2:Number Type="number">111</ns2:Number>
</ns2:Number>
</ns2:Thoroughfare>
<ns2:Postal>
<ns2:PostalCode>
<ns2:Number>
<ns2:Number>5014</ns2:Number>
</ns2:Number>
</ns2:PostalCode>
</ns2:Postal>
</ns2:AddressDetails>
<DPID>494852</DPID>
<Geospatial>
<ns3:Point
xmlns:ns3="http://aplt.nzpost.co.nz/schemas/common">
<ns3:Coordinate>174.953883,-41.271187</ns3:Coordinate>
</ns3:Point>
</Geospatial>
</ResultRecord>
<ResultRecord Type="URBAN">
<ns4:AddressDetails
xmlns:ns4="urn:nzpost:schemas:xAL:3.0">
<ns4:Locality>
<ns4:Name>UPPER HUTT</ns4:Name>
</ns4:Locality>
<ns4:Thoroughfare>
<ns4:Name>MAIN STREET</ns4:Name>
<ns4:Number>
<ns4:Number
Type="number">111</ns4:Number>
<ns4:Number
Type="alpha">A</ns4:Number>
</ns4:Number>
</ns4:Thoroughfare>
<ns4:Postal>
<ns4:PostalCode>
<ns4:Number>
<ns4:Number>5018</ns4:Number>
</ns4:Number>
</ns4:PostalCode>
</ns4:Postal>
</ns4:AddressDetails>
<DPID>2697192</DPID>
<Geospatial>
<ns5:Point
xmlns:ns5="http://aplt.nzpost.co.nz/schemas/common">
<ns5:Coordinate>175.070066,-41.124317</ns5:Coordinate>
</ns5:Point>
</Geospatial>
</ResultRecord>
<ResultRecord Type="URBAN">
<ns6:AddressDetails
xmlns:ns6="urn:nzpost:schemas:xAL:3.0">
<ns6:Locality>
<ns6:Name>WELLINGTON</ns6:Name>
<ns6:DependentLocality>
<ns6:Name>TAWA</ns6:Name>
</ns6:DependentLocality>
</ns6:Locality>
<ns6:Thoroughfare>
<ns6:Name>MAIN ROAD</ns6:Name>
<ns6:Number>
<ns6:Number Type="number">111</ns6:Number>
</ns6:Number>
</ns6:Thoroughfare>
<ns6:Postal>
<ns6:PostalCode>
<ns6:Number>
<ns6:Number>5028</ns6:Number>
</ns6:Number>
</ns6:PostalCode>
</ns6:Postal>
</ns6:AddressDetails>
<DPID>1066466</DPID>
<Geospatial>
<ns7:Point
xmlns:ns7="http://aplt.nzpost.co.nz/schemas/common">
<ns7:Coordinate>174.824326,-41.174181</ns7:Coordinate>
</ns7:Point>
</Geospatial>
</ResultRecord>
<ResultRecord Type="URBAN">
<ns8:AddressDetails
xmlns:ns8="urn:nzpost:schemas:xAL:3.0">
<ns8:Locality>
<ns8:Name>WELLINGTON</ns8:Name>
<ns8:DependentLocality>
<ns8:Name>KARORI</ns8:Name>
</ns8:DependentLocality>
</ns8:Locality>
<ns8:Thoroughfare>
<ns8:Name>MAKARA ROAD</ns8:Name>
<ns8:Number>
<ns8:Number Type="number">111</ns8:Number>
</ns8:Number>
</ns8:Thoroughfare>
<ns8:Postal>
<ns8:PostalCode>
<ns8:Number>
<ns8:Number>6012</ns8:Number>
</ns8:Number>
</ns8:PostalCode>
</ns8:Postal>
</ns8:AddressDetails>
<Geospatial>
<ns9:Point
xmlns:ns9="http://aplt.nzpost.co.nz/schemas/common">
<ns9:Coordinate>174.717753 , -41.284415</ns9:Coordinate>
</ns9:Point>
</Geospatial>
</ResultRecord>
</SearchResults>
</GetAddressSearchResponse>
</searchReturn></searchResponse></soapenv:
Body></soapenv:Envelope>
My cursor that gets any errors returned appears ok. This is:
CURSOR c_xml_err(i_xml IN XMLType, i_xmlns IN VARCHAR2) IS
SELECT extract(value(xmlseq), '/Errors' , i_xmlns) vi_errors
,extract(value(xmlseq), '/Warnings' , i_xmlns) vi_warnings
FROM TABLE(xmlSequence(extract(i_xml, '/GetAddressSearchResponse/ns1:ResponseHeader' , i_xmlns))) xmlseq;
i_xml that is passed in is an XMLType converted from a CLOB which is the response from the web service:
v_xml_response := XMLType(i_response);
i_response is the SOAP package above with the following done on it:
-- Strip the unnecessary SOAP XML envelope from the response
v_xml_resp := XMLType.createXml(o_response);
i_response := v_xml_resp.extract('/soap:Envelope/soap:Body/child::node()'
,'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"').getClobVal();
i_response is defined with a type of CLOB.
i_xmlns that is passed in is: 'xmlns:ns1="' || i_xml_namespace || '"' where i_xml_namespace is: http://aplt.nzpost.co.nz/schemas/search
My cursor that tries to get the address details returned is:
CURSOR c_xml(i_xml IN XMLType, i_xmlns IN VARCHAR2) IS
SELECT extract(value(xmlseq), '/ResultRecord/AddressDetails/Postal.PostBox.Number/text()' , i_xmlns).getNumberVal() box#
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Thoroughfare.Number/text()' , i_xmlns).getStringVal() street_number
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Thoroughfare.Name/text()' , i_xmlns).getStringVal() street_name
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Locality.DependentLocality.Name/text()' , i_xmlns).getStringVal() suburb
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Locality.Name/text()' , i_xmlns).getStringVal() town_city
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Postal.PostalCode.Number/text()' , i_xmlns).getStringVal() post_code
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Postal.PostOffice.Name/text()' , i_xmlns).getStringVal() box_lobby_name
,extract(value(xmlseq), '/ResultRecord/AddressDetails/Postal.PostRoute.Name/text()' , i_xmlns).getStringVal() rd_number
FROM TABLE(xmlSequence(extract(i_xml, '/GetAddressSearchResponse/SearchResults' , i_xmlns))) xmlseq;
This is not correct because it doesn’t select anything. The i_xml parameter passed in is the same as above however the i_xmlns parameter that is passed into this cursor is different. It’s currently passed in as:
'xmlns:ns2="urn:nzpost:schemas:xAL:3.0"'
Which matches what is returned in the soap message (first the first address match returned):
<ResultRecord Type="URBAN">
<ns2:AddressDetails
xmlns:ns2="urn:nzpost:schemas:xAL:3.0">
I'm calling this cursor in loop as follows:
for r_cu in c_xml(v_xml_response, v_xml_namespace)
loop
dbms_output.put_line('***** test12 - ws_avs_clients - IN LOOP - delete/insert nzp23_address');
Nothing gets returned.
Firstly, I’m not sure how to cater for n2, n3, n4, n5, etc which are the namespaces returned and incremented for each address match.
I’m also wondering if my cursor should be changed to something like:
CURSOR c_xml(i_xml IN XMLType, i_xmlns IN VARCHAR2) IS
SELECT extract(value(xmlseq), '/Postal.PostBox.Number/text()' , i_xmlns).getNumberVal() box#
,extract(value(xmlseq), '/Thoroughfare.Number/text()' , i_xmlns).getStringVal() street_number
,extract(value(xmlseq), '/Thoroughfare.Name/text()' , i_xmlns).getStringVal() street_name
,extract(value(xmlseq), '/Locality.DependentLocality.Name/text()' , i_xmlns).getStringVal() suburb
,extract(value(xmlseq), '/Locality.Name/text()' , i_xmlns).getStringVal() town_city
,extract(value(xmlseq), '/Postal.PostalCode.Number/text()' , i_xmlns).getStringVal() post_code
,extract(value(xmlseq), '/Postal.PostOffice.Name/text()' , i_xmlns).getStringVal() box_lobby_name
,extract(value(xmlseq), '/Postal.PostRoute.Name/text()' , i_xmlns).getStringVal() rd_number
FROM TABLE(xmlSequence(extract(i_xml, '/GetAddressSearchResponse/SearchResults/ResultRecord/ns2:AddressDetails' , i_xmlns))) xmlseq;
However I couldn’t have the ns2: before “AddressDetails” because this gets incremented. I don’t think I can also have the i_xmlns namespace parameter passed in as 'xmlns:ns2="urn:nzpost:schemas:xAL:3.0"'
because the ns2 gets incremented for each address.
I'm looking for any examples of pl/sql code that extracts the addresses from the SOAP message returned like I’m trying to do?
Any help would be much appreciated.
Thanks,
BradYou can find some examples in both the {forum:id=34} and {forum:id=75} forums. Just search on soap:Envelope or soap:Body and you should get some hits back.
Since you are using 10.2, you will want to use XMLTable instead of TABLE(xmlSequence(extract as XMLTable is the direction Oracle is going. As for ns2:, ns4: it doesn't matter what namespace prefix you use in your XPath statement as long as all the prefixes resolve to the same namespace.
Here is a starter piece of code that puts all that together for you.
SELECT town_city, peeking
FROM XMLTABLE(XMLNamespaces(default 'http://aplt.nzpost.co.nz/schemas/search',
'urn:nzpost:schemas:xAL:3.0' as "adns"),
'/GetAddressSearchResponse/SearchResults/ResultRecord/adns:AddressDetails'
PASSING XMLTYPE('<GetAddressSearchResponse xmlns="http://aplt.nzpost.co.nz/schemas/search">
<SearchResults SearchType="StreetAddress">
<ResultRecord Type="URBAN">
<ns2:AddressDetails xmlns:ns2="urn:nzpost:schemas:xAL:3.0">
<ns2:Locality>
<ns2:Name>LOWER HUTT</ns2:Name>
</ns2:Locality>
</ns2:AddressDetails>
</ResultRecord>
<ResultRecord Type="URBAN">
<ns4:AddressDetails xmlns:ns4="urn:nzpost:schemas:xAL:3.0">
<ns4:Locality>
<ns4:Name>UPPER HUTT</ns4:Name>
</ns4:Locality>
</ns4:AddressDetails>
</ResultRecord>
</SearchResults>
</GetAddressSearchResponse>')
-- The above XMLType would be your variable instead of what is hard-coded
COLUMNS
town_city VARCHAR2(30) PATH '/adns:AddressDetails/adns:Locality/adns:Name',
peeking XMLTYPE PATH '.'); -- This var is just to show you what each iteration is working with.You can also assign a namespace prefix to one of the default namespaces if your XPath goes across multiple "default" namespaces.
SELECT town_city, peeking
FROM XMLTABLE(XMLNamespaces('http://aplt.nzpost.co.nz/schemas/search' as "def", -- made up this prefix
'urn:nzpost:schemas:xAL:3.0' as "adns"),
'/def:GetAddressSearchResponse/def:SearchResults/def:ResultRecord/adns:AddressDetails'
PASSING XMLTYPE('<GetAddressSearchResponse xmlns="http://aplt.nzpost.co.nz/schemas/search">
<SearchResults SearchType="StreetAddress">
<ResultRecord Type="URBAN">
<ns2:AddressDetails xmlns:ns2="urn:nzpost:schemas:xAL:3.0">
<ns2:Locality>
<ns2:Name>LOWER HUTT</ns2:Name>
</ns2:Locality>
</ns2:AddressDetails>
</ResultRecord>
<ResultRecord Type="URBAN">
<ns4:AddressDetails xmlns:ns4="urn:nzpost:schemas:xAL:3.0">
<ns4:Locality>
<ns4:Name>UPPER HUTT</ns4:Name>
</ns4:Locality>
</ns4:AddressDetails>
</ResultRecord>
</SearchResults>
</GetAddressSearchResponse>')
-- The above XMLType would be your variable instead of what is hard-coded
COLUMNS
town_city VARCHAR2(30) PATH '/adns:AddressDetails/adns:Locality/adns:Name',
peeking XMLTYPE PATH '.'); -- This var is just to show you what each iteration is working with.Hope that helps as a starter to working on your problem.
If you follow the FAQ link in the above right, you will see how to use the { code } tag (without spaces) to wrap the examples and retain formatting as shown above. -
Problems with XMLType and namespace
Dear subscribers:
I have been using XMLType successfully with simple XMLs - without namespaces. Now I must handle messages with "xmlns" and it seems XMLType is failing.
I tested the following XML, extracted from w3c.org examples:
<?xml version="1.0"?>
<bk:book xmlns:bk=''urn:loc.gov:books''
xmlns:isbn=''urn:ISBN:0-395-36341-6''>
<bk:title>Cheaper by the Dozen</bk:title>
<isbn:number>1568491379</isbn:number>
</bk:book>
The result of xmlt.getRootElement() is book.
However, the use of xmlt.extract( 'book' ) returns an empty object:
xmlt1 := xmlt.extract( 'book' );
dbms_output.put_line( 'StringVal: ' || xmlt1.getStringVal() );
ORA-30625: method dispatch on NULL SELF argument is disallowed
The following usages also raise errors:
xmlt1 := xmlt.extract( 'bk:book' );
ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00601: Invalid token in: 'bk:book' ORA-06512: at "SYS.XMLTYPE", line 111
xmlt1 := xmlt.extract( 'bk::book' );
ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00601: Invalid token in: 'bk::book' ORA-06512: at "SYS.XMLTYPE", line 111
xmlt1 := xmlt.extract( 'book', 'bk' );
ORA-31013: Invalid XPATH expression ORA-06512: at "SYS.XMLTYPE", line 119
I am using Oracle version 10.2.0.1.0. Had someone also faced this problem?
The code I used to test is at the end of this message.
Thanks in advance
====================================
DECLARE
xml varchar2(32000);
xmlt XMLType;
xmlt1 XMLType;
root varchar2(3000);
BEGIN
--Example from w3c.org
xml := '<?xml version="1.0"?>
<bk:book xmlns:bk=''urn:loc.gov:books''
xmlns:isbn=''urn:ISBN:0-395-36341-6''>
<bk:title>Cheaper by the Dozen</bk:title>
<isbn:number>1568491379</isbn:number>
</bk:book>';
xmlt := XMLType( xml );
root := xmlt.getRootElement();
dbms_output.put_line( 'StringVal: ' || xmlt.getStringVal() ); -- The XML is ok
dbms_output.put_line( 'Namespace: ' || xmlt.getNameSpace() ); -- Returns NULL
dbms_output.put_line( 'Root element: ' || root ); -- Returns book
dbms_output.put_line( 'Exists: ' || xmlt.existsNode('book') ); -- Returns ZERO
xmlt1 := xmlt.extract( 'bk:book' ); Raises error (see above)
xmlt1 := xmlt.extract( 'bk::book' ); Raises error (see above)
xmlt1 := xmlt.extract( 'book', 'bk' ); Raises error (see above)
--xmlt1 := xmlt.extract( 'book' );
dbms_output.put_line( 'StringVal: ' || xmlt1.getStringVal() ); Raises error
END;
/If you put your XML into a namespace then you also need to extract from that namespace.... e.g.
No namespace...
SQL> select t.xml.extract('myroot')
2 from (select XMLTYPE('<myroot><mychild>test</mychild></myroot>') as xml from dual) t
3 ;
T.XML.EXTRACT('MYROOT')
<myroot>
<mychild>test</mychild>
</myroot>Put XML in namespace and now the extract returns nothing...
SQL> ed
Wrote file afiedt.buf
1 select t.xml.extract('myroot')
2* from (select XMLTYPE('<myroot xmlns="fred"><mychild>test</mychild></myroot>') as xml from dual) t
3 /
T.XML.EXTRACT('MYROOT')
--------------------------------------------------------------------------------------------------------Extract, specifying the namespace to extract from and now returns the result...
SQL> ed
Wrote file afiedt.buf
1 select t.xml.extract('myroot', 'xmlns="fred"')
2* from (select XMLTYPE('<myroot xmlns="fred"><mychild>test</mychild></myroot>') as xml from dual) t
SQL> /
T.XML.EXTRACT('MYROOT','XMLNS="FRED"')
<myroot xmlns="fred">
<mychild>test</mychild>
</myroot>
SQL>;) -
Unpredictable problem using XMLTYPE in Oracle 11g?
We recently upgraded from Oracle 10g to Oracle 11g, which caused some of our stored procedures to start acting funny.
Our database stores BLOBs containing XML data in a table. We then asynchronously convert these BLOBs into XMLTYPE objects, and use them to perform operations in our database. This logic started failing when we moved to 11g.
Our original code looked like this:
PROCEDURE submitTpfdd(shipmentDataId IN VARCHAR2) AS
shipmentData XMLTYPE;
csid INTEGER;
shipmentName VARCHAR(128);
gk_namespaces VARCHAR(1024) := 'xmlns:a="http://my.app/1.0.0.0"';
BEGIN
SELECT NLS_CHARSET_ID('UTF8') INTO csid FROM dual;
SELECT XMLTYPE(tf.shipmentData, csid)
INTO shipmentData
FROM SHIPQ.SHIPMENT_FILE tf
WHERE tf.shipment_id = shipmentDataId;
shipmentName := shipmentData.extract('/a:Shipment/shipmentName/text()', gk_namespaces).getStringVal();
... (more logic)
END submitTpfdd;When we switched to 11g, this code started frequently failing with an "unsupported character set" error. It happens about half the time, and it's unpredictable. It will sometimes pass and sometimes fail, even if the same BLOB is being read both times. I haven't been able to reproduce the error with any of XMLTYPE's other constructors.
Has anybody encountered similar behavior with the XMLTYPE in 11g? Should I submit a tracker?I have created a SQL program which can be run independently to reproduce the problem.
DECLARE namespaces constant VARCHAR2(1024) := 'xmlns:a="http://morton.com/"';
CURSOR cursor0(reeves XMLTYPE) IS
SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
bullock
FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
CURSOR cursor1(reeves XMLTYPE) IS
SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
bullock
FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
CURSOR cursor2(reeves XMLTYPE) IS
SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
bullock
FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
CURSOR cursor3(reeves XMLTYPE) IS
SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
bullock
FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
CURSOR cursor4(reeves XMLTYPE) IS
SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
bullock
FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
CURSOR cursor5(reeves XMLTYPE) IS
SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
bullock
FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
CURSOR cursor6(reeves XMLTYPE) IS
SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
bullock
FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
CURSOR cursor7(reeves XMLTYPE) IS
SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
bullock
FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
CURSOR cursor8(reeves XMLTYPE) IS
SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
bullock
FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
CURSOR cursor9(reeves XMLTYPE) IS
SELECT EXTRACT(VALUE(t), 'text()').getstringval() AS
bullock
FROM TABLE(xmlsequence(reeves.EXTRACT('/a:hopper', namespaces))) t;
xml_clob CLOB := empty_clob;
xml_blob BLOB := empty_blob;
xml_varchar VARCHAR2(4000);
xml_xmltype XMLTYPE;
warning INTEGER;
dest_offset INTEGER := 1;
src_offset INTEGER := 1;
lang_context INTEGER := 0;
char_set INTEGER := nls_charset_id('UTF8');
BEGIN
dbms_lob.createtemporary(xml_clob, TRUE);
dbms_lob.createtemporary(xml_blob, TRUE);
dbms_lob.OPEN(xml_clob, dbms_lob.lob_readwrite);
dbms_lob.OPEN(xml_blob, dbms_lob.lob_readwrite);
xml_varchar := '<a:hopper xmlns:a="http://morton.com"/>';
dbms_lob.writeappend(xml_clob, length(xml_varchar), xml_varchar);
dbms_lob.converttoblob(xml_blob, xml_clob, dbms_lob.lobmaxsize, dest_offset, src_offset, char_set, lang_context, warning);
xml_xmltype := XMLTYPE(xml_blob, char_set);
FOR daniels IN cursor0(xml_xmltype)
LOOP
CONTINUE;
END LOOP;
FOR daniels IN cursor1(xml_xmltype)
LOOP
CONTINUE;
END LOOP;
FOR daniels IN cursor2(xml_xmltype)
LOOP
CONTINUE;
END LOOP;
FOR daniels IN cursor3(xml_xmltype)
LOOP
CONTINUE;
END LOOP;
FOR daniels IN cursor4(xml_xmltype)
LOOP
CONTINUE;
END LOOP;
FOR daniels IN cursor5(xml_xmltype)
LOOP
CONTINUE;
END LOOP;
FOR daniels IN cursor6(xml_xmltype)
LOOP
CONTINUE;
END LOOP;
FOR daniels IN cursor7(xml_xmltype)
LOOP
CONTINUE;
END LOOP;
FOR daniels IN cursor8(xml_xmltype)
LOOP
CONTINUE;
END LOOP;
FOR daniels IN cursor9(xml_xmltype)
LOOP
CONTINUE;
END LOOP;
END;If someone else could run this program and verify that it acts unpredictably, that would be helpful. I have submitted a metalink tracker but the person who is working the tracker is not able to duplicate the same behavior. -
Can't fetch JSON value and extract to parameter
I need to extract this specific JSON-field into a parameter for my performance test in Visual Studio:
"ExamAnswerId": "757a3735-e626-412b-934c-e577c6963d51"
the problem occurs when I try to do this manually by right clicking the response and click "add extraction rule". The text is split up into 3 different rows with lots of unreadable numbers next to it like this: "0x00000000 7B 22 45 78 61 6D 41
6E 73 77 65 72 49 64 22 3A {"ExamAnswerId": 0x00000010 22 37 35 37 61 33 37 33 35 2D 65 36 32 36 2D 34 "757a3735-e626-4
This will sound dumb, but I somehow need to extract 3 different parameters, only because I can't copy/paste it -- and this is also where I think I fail.
the ExamAnswerId is important for me to fullfill another webrequest later on, but I can't seem to pass it on properly.
all input greatly appreciated !Hi Vegardontic,
There is a few ways to go about extracting JSON from a response. If you know the left and right boundary's such as the example you gave with ExamAnswerId you can always manually add a text extraction rule as seen below. To do this
set the starts with field equal to "ExamAnsersId": "" keep in mind the extra quotes and the ends with field equal to """. This should pull the items located in that specific JSON location.
A more advanced way of approaching this would be to parse the JSON which is being returned. I have included a few URL's which will help you if you decide to choose that route.
http://blogs.msdn.com/b/ambhrin/archive/2011/05/20/parsing-json-to-extract-values-for-further-parameterization-amp-correlation-test-automation-with-visual-studio.aspx
http://apmblog.compuware.com/2009/04/20/how-to-test-jquery-enabled-apps-using-json-with-visual-studio/
Regards,
Matt M. -
Extracting xmltype from table into xml output: redundant nodes
Hi guys - see the below example. (edit: sorry, haven't used these forums for a while and can't seem to figure out how to format code.....)
[code]SQL> select *
2 from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
[/code]
[/code]
SQL> create table mytesttable (item_id number, x_data xmltype);
Table created.
SQL>
SQL> insert into mytesttable
2 with dat as (select 'blah' item from dual
3 union all
4 select 'more blah' from dual)
5 ,t as (select xmlelement("x_data"
6 ,xmlattributes(1 as "dummyattr")
7 ,xmlagg(xmlelement("item"
8 ,item))
9 ) x_data
10 from dat
11 )
12 select 1,x_data
13 from t ;
1 row created.
SQL>
SQL> select *
2 from mytesttable;
ITEM_ID
X_DATA
1
<x_data dummyattr="1">
<item>blah</item>
<item>more blah</item>
</x_data>
1 row selected.
SQL>
SQL> select xmlelement("outerelement"
2 ,xmlelement("itemID", item_id)
3 ,xmlelement("x_data",x_data)
4 )
5 from mytesttable;
XMLELEMENT("OUTERELEMENT",XMLELEMENT("ITEMID",ITEM_ID),XMLELEMENT("X_DATA",X_DATA))
<outerelement><itemID>1</itemID><x_data><x_data dummyattr="1">
<item>blah</item>
<item>more blah</item>
</x_data>
</x_data></outerelement>
1 row selected.
[/code]
As the above, I have an xmltype in a table which has other non-xmltype columns. I have a requirement to extract them out into a single xml document in a similar way to the last SQL there.
the problem is if I do it as per the above, I artificially add a redundant node. the first <x_data> node is not necessary, but how do I go and add the xmltype column to the result without having to qualify it with another element around it?
i.e. how do I get the following:
<outerelement><itemID>1</itemID><x_data dummyattr="1">
<item>blah</item>
<item>more blah</item>
</x_data></outerelement>nevermind.. I was having a dumb moment:
select xmlelement("outerelement"
,xmlelement("itemID", item_id)
,x_data
from mytesttable;
Maybe you are looking for
-
Within the last few months I have gotten several snap shots of conversations from friends that showed it was my phone number but the conversation was not from me. It was someone using my information but texting frieda, family, and some co workers ve
-
Hi, After I installed OS X Yosemite Beta on my external hard drive, my Macbook Pro no longer recognises and boots from the Mavericks partition on my internal drive. instead, it starts up the Yosemite installer even when the external drive is not conn
-
Scripts-window is not printing repetedly
Hi all am working on scripts.(Goods receipt note). I have four line items in main window from mseg table. I have to display text related to that line items which is stored in mseg-sgtxt in seperate widow.(eg: remarks) But am getting the last line it
-
Hi, I received a Macbook pro as a gift. Unfortunately it came with a different os installed. To be more precise it now runs on windows 8. Can someone please help me by telling me how I can uninstall this os and install mavericks.?
-
Seeking help to create new apple ID
i am new user of apple mobiles. while creating apple ID. I have typed my mail address which is not at all existing. Now to create new apple ID what i need to do? Please do help me