Questions tagged [xquery-sql]

the XQuery language as supported by database systems. Include the tag of your system to specify ("sql-server", "oracle", "postgresql", etcetera). Use the "xquery" tag on its own for general questions about XQuery.

XQuery is a query language designed to extract data from arbitrary XML documents. Multiple RDBMSes support XQuery as part of the SQL/XML standard or using proprietary syntax. What follows is a non-exhaustive list.

Microsoft SQL Server

In SQL Server 2005 and onwards, the xml data type methods, in particular .query(), support querying XML and returning the results as relational data. These methods support a subset of XQuery, with special support for some T-SQL specific constructs like variables -- see the XQuery Language Reference for specifics.

Oracle

Oracle includes XML support as Oracle XML DB. It supports XQuery both for querying and updating data, both relational and XML. The XMLQUERY function is used to issue XQuery queries within an SQL statement.

453 questions
0
votes
1 answer

Apply IF EXISTS to the results of XQuery

I have an XQuery that checks for the existence of Rebuild Index tasks in SQL Server 2008 R2 maintenance plans. How do I wrap an IF EXISTS around this, or use the .exist XQuery method? I just want to get a boolean from this query based on whether…
dev_etter
  • 1,156
  • 13
  • 32
0
votes
1 answer

Xquery to get the value of a specific element from an XML which is stored as [XML Nullable column] in DB2

Consider the following XML : huff Above XMLis stored as a column(DATA) with data type [XML NULLABLE] in a table in DB2. Assume that the…
MrRavi
  • 35
  • 7
0
votes
1 answer

Invoking database using xquery giving duplicate values

I am using a XQuery to query database in an OSB project. Consider the following table: userId Name Category ------ ------- -------- 1 Dheepan Student 2 Raju Student and the XQuery let $userName:=fn-bea:execute-sql( …
JPS
  • 2,730
  • 5
  • 32
  • 54
0
votes
0 answers

Xquery ERROR err:XPDY0002: undefined value for variable $skill

I am trying to use xquery for a project and I cannot see why this query is not working. It gives me the following error: err:XPDY0002: undefined value for variable $skill I am new to xquery and I am using EXIST DB as a database and I have tried…
Vamsi Varanasi
  • 115
  • 1
  • 1
  • 6
0
votes
2 answers

SQL Server performance in xquery with for loop

I have one sql table with xml column, which holds the value like following xml format
Kevin M
  • 5,436
  • 4
  • 44
  • 46
0
votes
1 answer

XPath on XML in SQLServer

What is wrong with this??? My task is next: I have a XML file and I need to show all cities wheare are no Mick. !!! Cities are not unique. So, for example, I has Mick-London, Tom-London, Charles-Paris. The right answer is Paris only. Query is for…
Tigran
  • 1,049
  • 3
  • 15
  • 31
0
votes
1 answer

Some advices about a project semi-structured data

I'm stydying to get an advanced degree in computer science and I have a course about completions of databases in which we study semi-structured data (xml) and how to work on them and information retrieval. The exam is to build a little project.…
SagittariusA
  • 5,289
  • 15
  • 73
  • 127
0
votes
1 answer

Using XQuery to Parse XML in a table column

I am running the following in SSMS 2008 to try to get data out of the nodes for ease of searching and limiting values. This is XML sent to us by vendors and we often need to search to find messages sent and currently, it is not optimized to split…
Jacrys
  • 692
  • 1
  • 7
  • 20
0
votes
2 answers

Been trying to write an xquery code that converts a flat xml to 5-level hierarchy xml file

Would like to convert the following flax xml file to 5-level hierarchy xml structure using xquery, so far the all the xquery code i have written did not work. 1999 8 5
JamesBond
  • 13
  • 4
0
votes
1 answer

Update XML variable in SQL Server 2005 with namespace

I'm trying to add a new node to an XML variable containing namespaces using TRANSACT SQL, but there is no error, nor the variable is updated. Here is what I have so far: declare @xml xml; set @xml = '
Oscar
  • 13,594
  • 8
  • 47
  • 75
0
votes
1 answer

sql server xml replace or delete

With the table below...what would the replace (or delete/insert) look like if I wanted to completely replace the contents of the xml column with something else...there would no similar nodes in common however I need the PK i to stay intact CREATE…
Bayrat
  • 161
  • 1
  • 3
  • 17
0
votes
1 answer

If Condition followed by a for loop not executing in Xquery

In one of the SOAP responses, I was trying to use the following Xquery code to check a condition followed by for loop. I was trying to get a count of some element and then use the if condition and based on that if condition, it should execute the…
Steve
  • 69
  • 1
  • 9
0
votes
1 answer

Sql server xquery returning element name

I have the following xml declare @xml xml = 'AAABBB'; select @xml.query('for $k in /Values return concat(",@", "=''", $k, "''")') It returns ,@='AAABBB' However I expect ,@a='AAA',@b='BBB' How to write the…
ca9163d9
  • 27,283
  • 64
  • 210
  • 413
0
votes
1 answer

Query SQL XML field on type

So I've got an xml field in my DB. Sometimes what I'm doing fails and I get the following in my field: No response received! How do I query my DB to return all rows where the xml field contains an errorMessage XML? So…
Liam
  • 27,717
  • 28
  • 128
  • 190
0
votes
2 answers

Xquery Multiple Results in a node

When I try to execute my Xquery Code on xml file, I am getting multiple results in one of my fields. Here is my xml file
user2133404
  • 1,816
  • 6
  • 34
  • 60