KBD

Keith Devens .com

Saturday, March 20, 2010 Flag waving
"It's no trick for talented people to be interesting, but it's a gift to be interested. We want... – Randy S. Nelson (dean of Pixar University)
← Unison File SynchronizerFuture-proof Movable Type URLs →

Daily link icon Tuesday, August 5, 2003

XPath queries in PostgreSQL XML text blobs

Even though I mostly hate XML, and don't use PostgreSQL, this is just damn cool:

Bill Humphries: PostgreSQL and XML:

I missed these extensions to PostgreSQL that allow you to store an XML document as a text blob, and use XPath expressions in the WHERE clauses of SQL statements.

Check out that link for lots of examples.

← Unison File SynchronizerFuture-proof Movable Type URLs →

Comments XML gif

83.67.23.68 wrote:

Why didn't he just do this

Create table mytable{
a varchar,
b varchar
}

insert into mytable('apples','green')
insert into mytable('apples','red')

select /mydatabase/mytable[@a = 'apples' position() = first())

∴ 83.67.23.68 | 7-Feb-2005 10:37am est | #6972

217.227.197.125 wrote:

I don't think your question is serious, but here is an answer:

select /mydatabase/mytable[@a = 'apples' position() = first()) is not possible in PostgreSQL because /mydatabase/mytable[@a = 'apples' position() = first()) is invalid SQL Smiley

∴ 217.227.197.125 | 6-May-2006 8:49am est | #9436

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

March 2010
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

I hate ASP.NET

I hate ASP... I was doing wonders​with PHP, then suddenly one of my​clients...

Johnies: Mar 17, 6:14am

Quantum physics and free will

I knew you were going to say that....

Tom Massey: Mar 15, 9:26pm

Generated in about 0.124s.

(Used 8 db queries)