How Inception is like metaprogramming

Tweet I saw the movie Inception over the weekend and after reading What a Programmer Sees When He Watches Inception, in which Marke Hallowell compared the dreams-within-dreams concept from the movie to a recursive function, I think I too see parallels between the movie and computer programming. I think a parallel exists between dreams-within-dreams and […]

Metaprogramming in SQL (Part 4)

Tweet In the past three posts, we have written metaprograms to create functions for comparing objects of built-in types, user-defined distinct types, ROW types, and ordinary ARRAY types. In today’s post, we will write a single metaprogram that can create comparison functions for all four.

Metaprogramming in SQL (Part 3)

Tweet In the first post in this series, I introduced the concept of metaprogramming in SQL using dynamic SQL and applied the technique to write a procedure that could generate comparison functions that compare two objects of any basic type. In the second post, I expanded the procedure to produce comparison functions that compare two […]

Metaprogramming in SQL (Part 2)

Tweet In the last post on this subject, we used dynamic SQL to generalize an integer comparison function into a stored procedure that builds comparison functions of any basic type. This served as a simple example, but did not really offer much benefit over using the ‘=’ operator. In today’s post, I will extend the […]

Metaprogramming in SQL (Part 1)

Tweet Metaprogramming can feel like magic. You call a function that you neither wrote nor imported from any library and, magically, it comes back with a result. Even more magical is how metaprogramming lets you do otherwise impossible things with your programming language. In “The Art of Metaprogramming”, Jonathan Bartlett’s developerWorks series, he lists three […]

Why you should program to interfaces in SQL

Tweet With DB2 9.7’s introduction of modules and the ability to create an alias on a module, you now have the ability to program to a function or procedure’s interface rather than its implementation. Why would you want to do this? In today’s post, I will go over reasons to program to an interface and […]

New in DB2 for LUW 9.7.2: UDF default parameters

Tweet IBM released DB2 for LUW 9.7.2 recently and, along with numerous quality improvements, there were a number of interesting new features. In today’s post, I will talk about the “default parameters in UDFs” feature and how that helped me shrink the amount of code I needed to write for one of my UDFs.

Do your uninstall scripts leave something behind?

Tweet Have you ever needed to write a pair of scripts: one to create some tables, data types, or user-defined functions and a second to uninstall the same? How do you test that the uninstall script did its job and didn’t leave any database objects behind? Today, using a tool that comes with DB2, I’ll […]

DB2 Stored Procedures and Defaults (Conclusion)

Tweet If you remember the previous post, I showed how moving some logic from an anonymous block into a scalar function caused the program to start reporting an SQL0577N, saying that the underlying procedure was trying to modify SQL data even though it was doing no such thing. The clue to the cause of the […]

DB2 Stored Procedures and Defaults

Tweet Have you ever spent a long time trying to figure out what was causing DB2 to give you a bizarre error message only to find that the root cause was a default you didn’t know was a default? I got just such a message the other day when writing an SQL stored procedure. In […]

  • Search