Support for the DataLink data type can be broken down into three
different components.
- 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.
- The DataLink File Manager (DLFM) is the component that maintains the link
status for the files on a server, and keeps track of meta-data for each file.
This code handles linking, unlinking, and commitment control issues. An
important aspect of DataLinks is that the DLFM need not 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.
- 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. Since 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 discussion below on prefixes.
When working with DataLinks, there are several steps that must
be taken to properly configure the system:
- TCP/IP must be configured on any systems that are going to be used when
working with DataLinks. This includes the systems on which the SQL tables
with DataLink columns are going to be created, as well as the systems that
will contain the objects to be linked. In most cases, this will be the same
system. Since the URL that is used to reference the object contains a TCP/IP
server name, this name must be recognized by the system that is going to contain
the DataLink. The command CFGTCP can be used to configure the TCP/IP names,
or to register a TCP/IP name server.
- The system that contains the SQL tables must have the Relational Database
Directory updated to reflect the local database system, and any optional remote
systems. The command WRKRDBDIRE can be used to add or modify information
in this directory. For consistency, it is recommended that the same names
be used as the TCP/IP server name and the Relational Database name.
- The DLFM server must be started on any systems that will contain objects
to be linked. The command STRTCPSVR *DLFM can be used to start the DLFM server.
The DLFM server can be ended by using the CL command ENDTCPSVR *DLFM.
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.
Add 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 since their path beings with a valid
prefix:
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: - The following directories, or any of their subdirectories, should not
be used as prefixes for DataLinks:
- /QIBM
- /QReclaim
- /QSR
- /QFPNWSSTG
- 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
Add 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 library TESTDB or PRODDB to be allowed to link objects
on this server. Use the following command:
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.