Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 410163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:51:42+00:00 2026-05-12T17:51:42+00:00

Here is an example of some TSQL that I would like to rewrite in

  • 0

Here is an example of some TSQL that I would like to rewrite in PL/SQL.

DECLARE @xml XML

SET @xml = '<theRange>
    <theRow><First>Bob</First><Last>Smith</Last><Age>30</Age></theRow>
    <theRow><First>Sue</First><Last>Jones</Last><Age>34</Age></theRow>
    <theRow><First>John</First><Last>Bates</Last><Age>40</Age></theRow>
</theRange>'

;WITH OpenedXML AS (
    SELECT  r.value('First[1]','varchar(50)') AS First,
        r.value('Last[1]','varchar(50)') AS Last,
        r.value('Age[1]','int') AS Age
    FROM @xml.nodes('//theRange/theRow') AS Row(r)
)
SELECT * 
FROM OpenedXML
WHERE Age BETWEEN 30 AND 35

Can anyone give me some direction here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:51:42+00:00Added an answer on May 12, 2026 at 5:51 pm

    a couple of methods are described in this SO:

    Oracle Pl/SQL: Loop through XMLTYPE nodes

    Update: it’s rather straightforward since both methods are pure SQL (you can call this SQL from PL/SQL or any tool that interacts with the DB):

    SQL> WITH openedXml AS (
      2  SELECT extractvalue(column_value, '/theRow/First') FIRST,
      3         extractvalue(column_value, '/theRow/Last') LAST,
      4         to_number(extractvalue(column_value, '/theRow/Age')) Age
      5    FROM TABLE(XMLSequence(XMLTYPE('<theRange>
      6      <theRow><First>Bob</First><Last>Smith</Last><Age>30</Age></theRow>
      7      <theRow><First>Sue</First><Last>Jones</Last><Age>34</Age></theRow>
      8      <theRow><First>John</First><Last>Bates</Last><Age>40</Age></theRow>
      9  </theRange>').extract('/theRange/theRow')))
     10  )
     11  SELECT *
     12    FROM openedxml
     13   WHERE age BETWEEN 30 AND 35;
    
    FIRST     LAST       AGE
    --------- -------- -----
    Bob       Smith       30
    Sue       Jones       34
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a stored proc that executes some dynamic sql. Here's the example
Ok here is some example data and the expected results I would like: 2011-06-26
Here's some example code: class Obj attr :c, true def == that p '=='
Just some example code here, but I have lists of strings that I want
I have html like so: <div class=foo> (<a href=forum.example.com>forum</a>) <p> Some html here.... </div>
I need some T-SQL that will show missing records. Here is some sample data:
I am trying to match some XML output in a SQL Server 2008 TSQL
I'm looking for something like break for loops. Here's some example code (using Symfony's
Here is some example data: data = data.frame(series = c(1a, 1b, 1e), reading =
I am developing a application using PHP. Some example code is here. $url =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.