Tuesday, May 22, 2012

Getting a UDF definition in DB2

Recently, I was looking to change few DB2 User defined functions I developed in the past, but couldn't find
their source code even though the User Defined functions were present in the database.   Here is a simple SQL that I used to extract the UDF definition from the DB2 Catalog.

select routinename, text from syscat.routines r where routinetype = 'F' and language = 'SQL' and routinename like 'MyRoutine%'


PS: I did have problems running the above SQL in DB2 Command Editor. It showed the Text name fields as SQL0423N Locator variable "1" does not currently represent any value. SQLSTATE=0F001.   Instead, running the above SQL frrom command line worked without any issues.


Hope this helps.

No comments: