Working with DataLinks

 

To work with DataLinks, understand the DataLink processing environment.

Support for the DataLink data type can be broken down into the following different components:

  1. The DB2® database support has a data type called DATALINK. This can be specified on SQL statements such as CREATE TABLE and ALTER TABLE. The column cannot have any default other than NULL. Access to the data must be using SQL interfaces. This is because the DataLink itself is not compatible with any host variable type. SQL scalar functions can be used to retrieve the DataLink value in character form. There is a DLVALUE scalar function that must be used in SQL to INSERT and UPDATE the values in the column.

  2. The DataLink File Manager (DLFM) is the component that maintains the link status for the files on a server and keeps track of metadata for each file. This code handles linking, unlinking, and commitment control issues. An important aspect of DataLinks is that the DLFM does not need to be on the same physical system as the SQL table that contains the DataLink column. So an SQL table can link an object that resides in either the same system's integrated file system or a remote server's integrated file system.

  3. The DataLink filter must be run when the file system tries operations against files that are in directories designated as containing linked objects. This component determines if the file is linked, and optionally, if the user is authorized to access the file. If the file name includes an access token, the token will be verified. Because there is extra overhead in this filter process, it is only run when the accessed object exists in one of the directories within a DataLink prefix. See the following discussion on prefixes.

When working with DataLinks, there are several steps that must be taken to properly configure the system:

Once the DLFM has been started, there are some steps needed to configure the DLFM. These DLFM functions are available via an executable script that can be entered from the QShell interface. To get to the interactive shell interface, use the CL command QSH. This will open a command entry screen from which you can enter the DLFM script commands. The script command dfmadmin -help can be used to display help text and syntax diagrams. For the most commonly used functions, CL commands have also been provided. Using the CL commands, most or all of the DLFM configuration can be accomplished without using the script interface. Depending on your preferences, you can choose to use either the script commands from the QSH command entry screen or the CL commands from the CL command entry screen.

Since these functions are meant for a system administrator or a database administrator, they all require the *IOSYSCFG special authority.

 

Adding a prefix

A prefix is a path or directory that will contain objects to be linked. When setting up the Data Links File Manager (DLFM) on a system, the administrator must add any prefixes that will be used for DataLinks. The script command dfmadmin -add_prefix is used to add prefixes. The CL command to add prefixes is Add Prefix to DataLink File Manager (ADDPFXDLFM) command.

For instance, on server TESTSYS1, there is a directory called /mydir/datalinks/ that contains the objects that will be linked. The administrator uses the command ADDPFXDLFM PREFIX('/mydir/datalinks/') to add the prefix. The following links for URLs are valid because their paths have valid prefixes:

http://TESTSYS1/mydir/datalinks/videos/file1.mpg 
or 
file://TESTSYS1/mydir/datalinks/text/story1.txt  

It is also possible to remove a prefix using the script command dfmadmin -del_prefix. This is not a commonly used function since it can only be run if there are no linked objects anywhere in the directory structure contained within the prefix name. Notes:

  1. The following directories, or any of their subdirectories, should not be used as prefixes for DataLinks:

    • /QIBM

    • /QReclaim

    • /QSR

    • /QFPNWSSTG

  2. Additionally, common base directories such as the following should not be used unless the prefix is a subdirectory within one of the base directories:

    • /home

    • /dev

    • /bin

    • /etc

    • /tmp

    • /usr

    • /lib

 

Adding a host database

A host database is a relational database system from which a link request originates. If the DLFM is on the same system as the SQL tables that will contain the DataLinks, then only the local database name needs to be added. If the DLFM will have link requests coming from remote systems, then all of their names must be registered with the DLFM. The script command to add a host database is dfmadmin -add_db and the CL command is Add Host Database to DataLink File Manager (ADDHDBDLFM) command. This function also requires that the libraries containing the SQL tables also be registered. For instance, on server TESTSYS1 where you have already added the /mydir/datalinks/ prefix, you want SQL tables on the local system in either TESTDB or PRODDB library to be allowed to link objects on this server. Use the following:

ADDHDBDLFM HOSTDBLIB((TESTDB) (PRODDB)) HOSTDB(TESTSYS1)
Once the DLFM has been started, and the prefixes and host database names have been registered, you can begin linking objects in the file system.

 

Parent topic:

Using DataLinks