Installing the DB SQL Extension Toolkit
You can install the DB SQL Extension Toolkit in your Db2 environment to add a variety of functions that perform XML processing, compression, hashing, and other analytics that you used in your Netezza SQL queries.
About this task
For the list of functions that are implemented, see Release notes.
Refer to this link for details of available functions https://www.ibm.com/support/knowledgecenter/en/SSULQD_7.2.1/com.ibm.nz.sqltk.doc/c_sqltk_plg_overview.html
- Db2 client driver must be installed on the system. CLPPLUS is required to run the setup.
- Database user credentials which has the privileges to create schema/functions in database.
./setup.py [-user USER -schema SCHEMA] {[-dsn DSN] | [-pw PASS -port PORT -db DATABASE -host HOST_IP]} [-cleanup]
-h, --help show this help message and exit
-user USER Username with which you want to register udx. Default is bluadmin.
-pw PW Password of -u user; prompts user if -u is provided.
-host HOST Host IP if you're using Db2WoC. Default is current host's IP.
-port PORT Port number in case of SSL connections. Default is 50000.
-db DB Database name. Default is BLUDB.
-dsn DSN Used in case of SSL connection mostly.
-schema SCHEMA Schema name in which user wants to register the UDXes. Default is $USER.
-cleanup Cleanup the sqltoolkit funtions created.
Procedure
Best practices
- NVARCHAR is internally handled in VARCHAR in Db2. Thus, registering the functions with VARCHAR variant only will internally handle NVARCHAR as well.
- ARRAY objects are fits in VARCHAR column of the table. It is user's responsibility to allocate
appropriate memory in VARCHAR.
For example, VARCHAR(100) might give error while adding multiple BIGINT values. However, changing it to VARCHAR(10000) will solve the issue.
- Since BYTEINT is converted to SMALLINT in db2, ARRAY(1) gives error for such query. User is advised to use ARRAY(2) , as BYTEINT values are handled in SMALLINT.
- User needs to use functions with schema name under which they are registered. Schema will be the user name with which the package was installed.
- Output representation is different for DOUBLE/BOOLEAN in Db2 compared to PDA. So, you might observe output difference in case you are using DOUBLE/BOOLEAN data types with the functions.
- If your workload/query involves "NCHAR", "NVARCHAR" data then your system must be set with appropriate STRING_UNITS configurations.
Uninstalling the DB SQL Extension Toolkit
The cleanup of the SQL Extension Toolkit requires the schema which was provided while installing. If not provided, the user with which the script is run will be treated as schema name.
Procedure
[bluadmin@host - Db2wh db_sqltoolkit_x86_64]$ ./setup.py -schema sqltk -cleanup
[INFO] : Checking required files ...
[INFO] : Connecting user bluadmin with 172.16.176.74:50000/BLUDB
Enter password for bluadmin :
[INFO] : STRING_UNITS detected as : SYSTEM
[INFO] : De-registering functions ...
[INFO] : Successfully operated ..
[bluadmin@host - Db2wh db_sqltoolkit_x86_64]$
Examples
- using connection
identifiers:
./setup.py -user bluadmin -host myhost_ip -schema db_toolkit
- using DSN:
./setup.py -user bluadmin -dsn MY_DSN -schema db_toolkit
- using connection
identifiers:
./setup.py -user bluadmin -host myhost_ip -schema db_toolkit -cleanup
- using
DSN:
./setup.py -user bluadmin -dsn MY_DSN -schema db_toolkit -cleanup