Migrating user-defined shared libraries from IBM PureData® System for Analytics (Netezza) to Db2 Warehouse

The process of creating and referencing user-defined shared libraries is different for PureData® System for Analytics and Db2® Warehouse. In PureData System for Analytics, the user-defined shared libraries are re-created by using the create library function. And the libraries that are using shared libraries are reregistered by using the dependencies parameter in the create function call. On Db2 Warehouse, every library that is built within a project can be used as a shared library and be referenced by other libraries.

Before you begin

You must consider the following limitations on Db2 Warehouse:
  • Only automatic load is supported.
  • The libraries can be referenced only within single user project.

About this task

The following example shows how to build a user-defined shared library.

Procedure

  1. Create the archives for the calling package and the called package by entering the following commands:
    tar -czf called.tar.gz opr.cpp opr.h
    tar -czf calling.tar.gz udsf1.cpp opr.h
  2. Build the shared library for the called project by using the ida buildlib CLPPlus command:
    SQL> ida buildlib project called source called.tar.g
  3. Build the actual user-defined library in the calling project and register the sl_udf UDX:
    SQL> ida deployudx proj calling source calling.tar.gz uselib called 
    class CUdf sig "sl_udf(integer, integer)" return integer

    To refer to a specific library within the package, replace the uselib called parameter with the uselib called:libcalled.so parameter. Without explicit specification, the default library name in the referenced project is created by adding the prefix lib and the extension .so to the project name.

Results

You can now use the UDX that references to the shared library as any other function, for example:
SQL> select sl_udf(col1, col2) from table1;