Unexpected for following namespace declaration

I ran into a problem running a simple test xquery. I hadn’t directly dealt with XML namespaces in xquery prior to this, but the documentation was clear enough:

XQUERY
declare default element namespace "http://posample.org"
for $x in db2-fn:xmlcolumn("PURCHASEORDER.PORDER")
return $x

Oops, EOF error. It needs a terminator.

XQUERY
declare default element namespace "http://posample.org"
for $x in db2-fn:xmlcolumn("PURCHASEORDER.PORDER")
return $x;

Unexpected “for” following the namespace declaration? Pardon? It turns out xquery prologs need to be terminated by a semicolon:

XQUERY
declare default element namespace "http://posample.org";
for $x in db2-fn:xmlcolumn("PURCHASEORDER.PORDER")
return $x;

Unexpected “http://posample.org”? But that’s the exact syntax given in the examples! Alas, this semicolon is distinct from the usual semicolon separator in SQL. It’s part of a single xquery statement, so what I need to do is change the SQL separator to something more exotic. This will allow xquery to be parsed correctly:

XQUERY
declare default element namespace "http://posample.org";
for $x in db2-fn:xmlcolumn("PURCHASEORDER.PORDER")
return $x@

Eureka.:)

Mapping DB2 databases after a reinstall

Due to the vagaries of software, I had to reinstall DB2 on my laptop. Unfortunately, the existing databases were not automatically added to the Control Center.

Physically, DB2 stores its databases in a directory similar to C:\DB2\NODE0000. Logically, there must a way to remap them. So, how does one remap them?

To list databases stored at a path:
% db2 list db directory on c:

To recatalog them:
% db2 catalog db SAMPLE on c:

Reference:
DB2 at a Glance | The DB2 Environment

WinSCP

Sometimes I develop on Linux, sometimes on Windows. It’s mostly Windows right now. I tend towards editing with UltraEdit (or the free Crimson Editor, uploading with WinSCP, and doing command-line stuff with Cygwin. If you just want ssh (new-fangled telnet), PuTTY is easier to get working.

If I keep doing PHP stuff, I might end up switching to the Eclipse PHP IDE. Stranger things have happenned.

There’s a list of useful Windows software on my wiki.