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

Return multiple XML nodes and Custom parent tag using FLWOR XQuery

I need to get the following output using a FLWOR expression. Cessna Centurian Piper Tripacer using CREATE TABLE XMLO1 (xDoc XML NOT NULL) INSERT INTO XMLO1…
Harsha W
  • 3,162
  • 5
  • 43
  • 77
0
votes
3 answers

How to use parameter in XQuery?

I'm trying to loop the XML value using @count variable, but I'm not able to understand how to use the parameter create function sbill(@s xml) returns varchar(max) as begin DECLARE @SBILLNO VARCHAR(MAX),@count int set @count =5 while @count <>…
0
votes
1 answer

Syntax error using sql:variable in an XML nodes SQL Server query

I've been working on a query to pull XML data from a SQL Server database. I want to extract a specific row from the XML. If I hard code the ID in the .nodes line, it works as intended, but I can't get past a syntax error when replacing the hard…
0
votes
1 answer

optimizing sql xml select query

XML value value2 Is it possible to run it somehow like this, to simply query: SELECT id, userId, …
dnkira
  • 362
  • 3
  • 8
0
votes
1 answer

How to write an XQUERY call with ora:view against another schema

I want to write an XQUERY call in Oracle SQL Developer but I keep getting an error. I have created a schema and table: ALTER SYSTEM SET deferred_segment_creation=false; CREATE USER bookdb IDENTIFIED BY abc123; GRANT RESOURCE TO bookdb; GRANT…
Red Eyez
  • 187
  • 3
  • 16
0
votes
1 answer

SQL Server XML - modify multiple elements

I have a SQL Server XML column with data like this: ..... ..... I need to add a unique identifier to each Entry element, giving this result:
Don Chambers
  • 3,798
  • 9
  • 33
  • 74
0
votes
2 answers

xquery loop over columns

I have been tasked with creating a service broker using Xquery to handle tracking changes on a collection of tables. I have figured out how to pass the messages (xml of column names and the updated and deleted tables for the statements). The aim is…
bdwakefield
  • 685
  • 2
  • 11
  • 24
0
votes
1 answer

XQuery in Sql Server 2005 - find node in same position

I'm trying to solve the following problem which results in the serialization of objects representing calculations in the database. I'm trying to perform a query for reporting purposes and need to find the node in the same position in a different…
Panto
  • 1
  • 2
0
votes
1 answer
0
votes
1 answer

number inside [] after in orderby in XQuery

Following is the query for $x in $books where $x/price>=38 order by ($x/price)[l] return ($x/title, $x/price) what is denoted by [1] located after order by($x/price)?
0
votes
1 answer

SQL XQuery to seperate children/descendants

I need to return 2 rows of data from the below XML. | FaultText | Question1 | Question2 | Question3 | SOR …
WRD299
  • 37
  • 11
0
votes
1 answer

xml.value()in Xquery only returns 1 record

I have multiple "abc" nodes in xml file but it is returning the value for the first row as we have specified [1] , if I write [2] , it returns the second row. I want to return all the values of "Element" in all "abc" loops. Query Used: Insert Into…
Cherry
  • 23
  • 6
0
votes
1 answer

How to implement paging in T-Sql XQuery

I have some XML, very simple in structure, but in some cases extremely large. ... The following simple query works very effectively to return a subset of…
Hugh Jones
  • 2,706
  • 19
  • 30
0
votes
1 answer

Syntax for xquery with namespace in the node

We are trying to get IdValue from sql query. We are using sql server 2005. DECLARE @MyXML XML SET @MyXML = '
vamsivanka
  • 792
  • 7
  • 16
  • 36
0
votes
1 answer

SQL XQuery; Update attribute in typed XML

I am attempting to update attributes in typed XML. I have done this in the past by building the XML in untyped objects then setting it to a typed object (so avoiding the issue), but I'd like to know how to modify the typed data directly. My schema…