Just send out an email to a larger internal email list. If the only type of response you receive are out of office emails, shut down your computer and start vacation, too.
Happy Summertime!
Henrik's thoughts on life in IT, data and information management, cloud computing, cognitive computing, covering IBM Db2, IBM Cloud, Watson, Amazon Web Services, Microsoft Azure and more.
Monday, July 25, 2011
Tuesday, July 19, 2011
A small update on updating XML data in DB2
Once you get started with processing XML data within a database, such as DB2, the next question usually is: How can I update XML documents? Well, (relational) database systems usually have an UPDATE statement for modifying data. In DB2, the same UPDATE can be used to change XML documents. The way it is done is to provide the new XML document which can be based on the previous version and then modified by applying expressions based on the XQuery Update Facility.
DB2 uses the so-called "transform expression" of that standard to let you describe (both SQL and XQuery are declarative query languages) how the new XML document should look like. Instead of providing an example here, I will give you the link to "Transform expression and updating expressions" in the DB2 Information Center. There you find plenty of examples to get you started.
The interesting aspect of the transform expression is that because it is an expression like any other in XQuery, you can combine it with the rest of XQuery and modify XML documents on the fly (e.g., in XMLQUERY or XMLTABLE), use it in "if-then-else" expressions to update documents conditionally, or come up with new ideas of how to use it.
DB2 uses the so-called "transform expression" of that standard to let you describe (both SQL and XQuery are declarative query languages) how the new XML document should look like. Instead of providing an example here, I will give you the link to "Transform expression and updating expressions" in the DB2 Information Center. There you find plenty of examples to get you started.
The interesting aspect of the transform expression is that because it is an expression like any other in XQuery, you can combine it with the rest of XQuery and modify XML documents on the fly (e.g., in XMLQUERY or XMLTABLE), use it in "if-then-else" expressions to update documents conditionally, or come up with new ideas of how to use it.
Thursday, July 14, 2011
Energy consumption for another year in our passive house
A third year of keeping the tab of our energy consumption has passed. Luckily, even with changing weather and sometimes frosty days, the kilowatt hours that we used over the past 12 months stayed almost the same. I had reported about the previous year last July. So how what do the energy meters say this year?
Let's see where we stand next year. I would be happy with small changes only as we have seen this year. What is your consumption?
- Household consumption: 2605 kWh (2010: 2473 kWh, 2009: 2244 kWh)
- Heating/ventilation/water: 2713 kWh (2010: 2858 kWh, 2009: 2782 kWh)
Let's see where we stand next year. I would be happy with small changes only as we have seen this year. What is your consumption?
Tuesday, July 12, 2011
Data inconsistency causing 30 minute flight delay
On Friday evening I was traveling back home. The last leg from FRA to FDH is with a regional jet which always is parked in an outside position and requiring a bus transfer from the terminal. I was happy because the bus was leaving the terminal 20 minutes before the departure time, usually a sign of on-time arrival (that's what counts). However, it turned out differently...
Once we arrived at the airplane, all the passengers boarded and took their seats. We then waited for the usual "boarding complete" and welcome message which didn't come. Instead, the flight attendants counted the passengers, re-counted, compared their passenger list with the seated crowd, and then got busy. At first, they asked the passengers in business class to show their boarding passes. After some more discussions, they went around in economy class and asking for specific passengers. Suddenly, at least for us boarded passengers, two more passengers were brought to the plane and also another car from operations arrived.
With some more discussions between crew, operations, and some passengers, the puzzle eventually got solved: It seemed that the crew was handed an outdated list (which they discovered) as there were some last-minute changes. Some of the new passengers arrived on time for boarding while some others on the first list arrived late. Hence we had a mix-up in the passenger count and with some names. All this caused a delayed departure of 30 minutes (and 20 minutes for arrival).
Once we arrived at the airplane, all the passengers boarded and took their seats. We then waited for the usual "boarding complete" and welcome message which didn't come. Instead, the flight attendants counted the passengers, re-counted, compared their passenger list with the seated crowd, and then got busy. At first, they asked the passengers in business class to show their boarding passes. After some more discussions, they went around in economy class and asking for specific passengers. Suddenly, at least for us boarded passengers, two more passengers were brought to the plane and also another car from operations arrived.
With some more discussions between crew, operations, and some passengers, the puzzle eventually got solved: It seemed that the crew was handed an outdated list (which they discovered) as there were some last-minute changes. Some of the new passengers arrived on time for boarding while some others on the first list arrived late. Hence we had a mix-up in the passenger count and with some names. All this caused a delayed departure of 30 minutes (and 20 minutes for arrival).
Monday, July 11, 2011
XQuery: Variable-based step in XPath expression
Recently I was asked how parts of an XPath expression can be passed into an XQuery in DB2. For performance, it is - of course - best to know all the steps when compiling a query. Let's look into the options by introducing an example:
Imagine a document where we have an element "greeting" inside either "b" or "c":
We want to search for either /a/b/greeting or /a/c/greeting and pass in the "b" or "c" as variable "qt" (query tag).
One option is to compose the entire statement inside the application by concatenating the query string, then executing it as dynamic SQL.
If the variable needs to be processed as part of a stored procedure, the query string could be composed inside the procedure, then prepared and executed using a cursor. The Information Center has a good example for such a procedure and XQuery for this second option.
A third option would be to process the variable as part of the XPath expression itself within XMLQUERY, XMLEXISTS, or XMLTABLE (XMLEXISTS shown):
We are using the XPath function fn:local-name() to access the element name and then comparing it against the passed in variable. Also note how we can use a parameter marker with our XQuery/XPath expression. The above works with namespaces, too. In that case use something like "/nsPrefix:*[local-name() eq $qt]/" in your XPath expression.
Imagine a document where we have an element "greeting" inside either "b" or "c":
<a>
<b><greeting>Hello</greeting></b>
<c><greeting>Moin</greeting></c>
</a>
We want to search for either /a/b/greeting or /a/c/greeting and pass in the "b" or "c" as variable "qt" (query tag).
One option is to compose the entire statement inside the application by concatenating the query string, then executing it as dynamic SQL.
qs="/a/"+qt+"/greeting";
If the variable needs to be processed as part of a stored procedure, the query string could be composed inside the procedure, then prepared and executed using a cursor. The Information Center has a good example for such a procedure and XQuery for this second option.
A third option would be to process the variable as part of the XPath expression itself within XMLQUERY, XMLEXISTS, or XMLTABLE (XMLEXISTS shown):
...
XMLEXISTS('$DOC/a/*[local-name() eq $qt]/greeting' PASSING (cast ? as varchar(60)) as "qt")
...
We are using the XPath function fn:local-name() to access the element name and then comparing it against the passed in variable. Also note how we can use a parameter marker with our XQuery/XPath expression. The above works with namespaces, too. In that case use something like "/nsPrefix:*[local-name() eq $qt]/" in your XPath expression.
Wednesday, July 6, 2011
Daddy in the cloud vs. Daddy as a Service vs. Traditional Daddy
I am traveling right now and this morning, on one of the flights ("in the cloud") I was reading a longer article about cloud computing and its adoption in the SMB market (small and medium businesses). Then, suddenly, it dawned on me. I, as a daddy, can be compared to a business critical application.
As a "traditional daddy", I am home quite often. My wife and kids have direct access to me and can (more or less) control what's going on - all at a price. I need food (chocolate, coffee, etc.), I need some care, sometimes there are outages or my family runs into "defects" that I have. Anyway, they like this "traditional daddy" and local hosting.
As "daddy in the cloud" I am available over the Internet and over the phone. Sometimes, my kids are that busy that they don't care whether they talk with daddy in person or over the phone. "Daddy in the cloud" is also cheaper than the "traditional daddy" because IBM is paying for the food. My wife has to cook less, has to buy less. There is less usage of water at home. All is good, except "daddy in the cloud" does not have all the extras of "traditional daddy". There are also questions about who can listen in to chats (on the phone or the Internet). Sometimes there are issues with scalability (customer needs daddy, family needs daddy - but only one daddy is available). Is this still an exclusive daddy or can others gain access to it...?
What is needed is "daddy as a service" with a service level agreement (SLA). However, based on the requirements, it will be hard to meet the SLA given that I can't beam back and forth...
As a "traditional daddy", I am home quite often. My wife and kids have direct access to me and can (more or less) control what's going on - all at a price. I need food (chocolate, coffee, etc.), I need some care, sometimes there are outages or my family runs into "defects" that I have. Anyway, they like this "traditional daddy" and local hosting.
As "daddy in the cloud" I am available over the Internet and over the phone. Sometimes, my kids are that busy that they don't care whether they talk with daddy in person or over the phone. "Daddy in the cloud" is also cheaper than the "traditional daddy" because IBM is paying for the food. My wife has to cook less, has to buy less. There is less usage of water at home. All is good, except "daddy in the cloud" does not have all the extras of "traditional daddy". There are also questions about who can listen in to chats (on the phone or the Internet). Sometimes there are issues with scalability (customer needs daddy, family needs daddy - but only one daddy is available). Is this still an exclusive daddy or can others gain access to it...?
What is needed is "daddy as a service" with a service level agreement (SLA). However, based on the requirements, it will be hard to meet the SLA given that I can't beam back and forth...
Subscribe to:
Posts (Atom)