I've a XML string like that stored on my DB:
<?xml version="1.0" encoding="utf-8"?>
<AddressMaintenance>
<Label Name="lblAddress11">Address Line 1</Label><TextBox Name="txtAddress11">Zuellig Korea</TextBox>
</AddressMaintenance>
do you know if there is a way to extract the value Zuelling Korea using XMLQuery or SQL? I can't create a temporary table because it's a validate environment so I can only read that value. I know is possible using reg exp, but, if possible I try to use XML.
thanks,
Andrea
If this is stored in an XMLTYPE on a table you can use the Oracle XML functions to extract it using XPath:
SELECT
extractvalue(xmlcol, '/*/TextBox[#Name=''txtAddress11'']') txtaddress
FROM yourtable
Adapt the XPath to suit your needs.
See ExtractValue documentation or research other Oracle XML functions.
I should probably note that 11g and later, extractvalue is deprecated and you should use XMLQuery
Related
I'm trying to access the columns stored inside this CLOB of JSON. However, because it is not version 12C of Oracle I cannot use dot notation to reference the column names like "table.column"
I am really struggling. I have tried to use dbms_lob.substr to extract it but i just end up getting the full CLOB.
My screenshot attached is displayed when running the following :
SELECT
*
FROM TRANSFORM_OB_BB_SIT_OWNER.BUCKETS
WHERE bucket_name ='LatestApplicationVersions'
However, I want to be able to access 'PersonalCountryOfNationality' where it is = 'United Kingdom' enter image description here
If you want to work with JSON with a version older than 12c, I recommend using the PLJSON package, here is a link:
https://github.com/pljson/pljson/tree/develop
You can find exemples here:
https://github.com/pljson/pljson/tree/develop/examples
I need to extract some tag values from a XML code saved in a CLOB type column in Oracle 12c table.
Earlier we were using xmltype(COLUMN).extract('XPath/text()').getStringVal() to extract data from tags but its not working after our database upgrade to 12c.
We have XML Like:
<otm:ShipmentStatus
xmlns:gtm="http://xmlns.oracle.com/apps/gtm/transmission/v6.4"
xmlns:otm="http://xmlns.oracle.com/apps/otm/transmission/v6.4">
<otm:ServiceProviderAlias>
<otm:ServiceProviderAliasQualifierGid>
<otm:Gid>
<otm:Xid>GLOG</otm:Xid>
</otm:Gid>
</otm:ServiceProviderAliasQualifierGid>
<otm:ServiceProviderAliasValue>TEST.123</otm:ServiceProviderAliasValue>
</otm:ServiceProviderAlias>
<otm:IntSavedQuery>
<otm:IntSavedQueryGid>
<otm:Gid>
<otm:DomainName>TEST</otm:DomainName>
<otm:Xid>FIND_DELIVERY_NUMBER</otm:Xid>
</otm:Gid>......etc.
From this XML we have to select some values.
Please suggest some way to solve this problem. Feel free to ask if you need anything more.
Thank You.
Satyam
Example xml has namespaces. And you have to use it.
xmltype.extract('/otm:ShipmentStatus', 'xmlns:gtm="http://xmlns.oracle.com/apps/gtm/transmission/v6.4"
xmlns:otm="http://xmlns.oracle.com/apps/otm/transmission/v6.4"') extacting node from specify namespace
xmltype.extract('/*:ShipmentStatus') extractin node from any namespace
I have got SQL Server 2005 and I want to get result like in the picture, I dont want to use for xml path method and make different way.
As #TT says in the comments "Concatenation with FOR XML PATH up until SQL Server 2016 is accepted as the best way to concatenate strings.", so you should use it.
I need to develop a sql server procedure which will convert table rows into xml and will transfer it to another stored procedure(Different server) through link server. On that server I have to take this xml data as input and again convert it into table rows. What will be the simplest and time efficient way to do this.
It is not possible to use the XML datatype as a parameter in stored procedure on a linked server. You have to use nvarchar(max) and convert to XML in the stored procedure.
To create the XML you should use FOR XML (SQL Server). RAW and AUTO is easy and if you need more control you could use PATH. I would stay away from EXPLICIT.
To shred the XML on the receiving side you should use nodes() Method (xml Data Type) and value() Method (xml Data Type).
Given that you are using SQL Server, you need only append FOR XML to your query.
Hi I have a blob of xml..
<string>1</string>
<string>2</string>
<string>3</string>
<string>4</string>
<string>11</string>
<string>1211</string>
<string>12331</string>
how would I get all the values using xpath/xquery in SQL
Thanks
The xpath //string will return all the values in the intire xml the xpath /string will return only the values in the root node.
And for using it in sql look at this post XPath to fetch SQL XML value
in oracle database
you have XMLType (see this) data type..
by this datatype you can get all the value..
all the examples are there itself, please go through that site.