BibleGateway.com Verse Of The Day

Wednesday, August 18, 2010

Good XSL And XPath Advice

A few months ago I came across a post that I've gotten a lot of mileage out of while working on the Oracle Service Bus (OSB). I can't remember where I saw it or who said it, otherwise I would cite it, but to paraphrase:
If your XPath query is not returning any results (and you think it should), it is almost always a namespace issue.

OK, so maybe it is common knowledge, common sense, or whatever for everyone else, but for me, remembering that one statement makes XSL, XPath, and XQuery much less frustrating to deal with.

Take that statement along with the issues with the default namespace, and it can be a lifesaver.

If you have an XML with a default namespace and try searching for, say "//somenode", it won't be found, because "//somenode" will only match somenode's without any namespace. The somenode's in an XML doc with a default namespace does have a namespace.

Oracle Sorting of NULL Values

Speaking of Oracle crap, a few weeks ago while working on this project, the question came up of how Oracle sorts NULL values in an ORDER BY clause. I looked it up, and learned something new. Hooray for learning new stuff. I didn't realize you can specify how to sort NULL's in your ORDER BY clause. You add "NULLS FIRST" or "NULLS LAST" like this....

SELECT * FROM sometable ORDER BY col1 ASC NULLS FIRST

ORA-24777 When Using XA Driver

Here's something we came across this past week, and after some searching, it appears to be a fairly common issue.

We are calling some PL/SQL stored procedures through JCA adapters on the Oracle Service Bus (OSB). Our connection pool on WebLogic is setup using the XA JDBC driver.

Everything was great until we called a stored procedure that queries across a database link. Then we got the dreaded ORA-24777 - use of non-migratable database link not allowed.

Turns out there are at least 3 ways to rectify this issue....

  1. Set up Oracle to use multi-threaded server, a.k.a. shared server. There are ups and downs, and depending on who you talk to, mostly downs, especially concerning performance. We haven't tried this, but it does come up often as a fix.
  2. Create a "shared" database link. The syntax is a little different than a "normal" link. This is what we did, and it worked fine.
  3. Third option, though not right for everyone, would be to use the non-XA driver.
Creating a shared link....
CREATE SHARED DATABASE LINK 
CONNECT TO IDENTIFIED BY
AUTHENTICATED BY IDENTIFIED BY
USING ;