KBD

Keith Devens .com

Saturday, October 11, 2008 Flag waving
The Lord is my shepherd; I shall not want. – David (Psalm 23)
← 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)
:

October 2008
SunMonTueWedThuFriSat
 1234
567891011
12131415161718
19202122232425
262728293031 



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

Recent comments XML

new⇒I hate PHP

Elliot Anderson,

Dude!! You the​man! The reverse replacement for​array_u...

Alex Ndungu: Oct 11, 1:35am

Call a function from a string in Python

?!code:
some_object.__getattribute​__('method_name')()
?!/code

is​the s...

Patrick Corcoran: Oct 8, 3:53pm

Spider solitaire

I have won 185 games of Spider​Solitaire at the "Difficult" level.​ What is...

75.179.28.113: Oct 8, 12:42pm

Sed one-liners

Hi.

I wanted to let you know​that I wrote an article "Famous Sed​One-Lin...

Peteris Krumins: Oct 8, 3:05am

Timesheet Calculator

Hadn't seen it before now, but my​company already uses a time​tracking prog...

Keith: Oct 7, 10:44am

Girls, please don't get breast implants

Hey everyone, 

I am new to this​blog and I have enjoyed reading all​your...

Sarah.M.: Oct 6, 9:45am

Generated in about 0.348s.

(Used 8 db queries)

mobile phone